現(xiàn)在前臺有一個option,怎么在后臺接收前面選擇的是哪個,并且存進數(shù)據(jù)庫。望大神解答。專業(yè)<select><option name="education" value="大專">大專</option><option name="education" value="本科" >本科</option><option name="education" value="研究生" >研究生</option></select><br/>
3 回答

maven233
TA貢獻5條經驗 獲得超3個贊
var obj = document.getElementByIdx_x(”testSelect”); //定位id
var index = obj.selectedIndex; // 選中索引
var text = obj.options[index].text; // 選中文本
var value = obj.options[index].value; // 選中值
jQuery中獲得選中select值
第一種方式
$('#testSelect option:selected').text();//選中的文本
$('#testSelect option:selected') .val();//選中的值
$("#testSelect ").get(0).selectedIndex;//索引
?
第二種方式
$("#tesetSelect").find("option:selected").text();//選中的文本
…….val();
…….get(0).selectedIndex;
- 3 回答
- 0 關注
- 1466 瀏覽
添加回答
舉報
0/150
提交
取消