Posted in Javascript onNovember 08, 2013
如何获取select下拉框的值:
1.下拉框的option没有value属性时
<select id="param1"> <option>学号</option> <option>姓名</option> <option>年龄</option> </seclect> <script> window.onload = funciton(){ var param = document.getElementById("param1"); param.onchange = getParam(){ var text = param.value; } } </script>
2.下拉框的option有value属性时
<select id="param1"> <option>学号</option> <option>姓名</option> <option>年龄</option> </seclect> <script> window.onload = funciton(){ var param = document.getElementById("param1"); param.onchange = getParam(){ var selectIndex = param.selectIndex; //获得被选项的引索号 var text = param.options[selectIndex].text; </script>
如何获取select下拉框的值(option没有及有value属性)
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@