当前位置:编程学习 > JS >>

如何在js中获取下拉列表选择的值

答案:<script language="javascript"> function getselectvalue() { var rtl=document.getElementById("rtl"); alert(rtl.options.(rtl.selectedIndex).value); } </script> 以楼上的数据来用 <select name="sel" id="rtl" > <option>菜单一</option> <option>菜单二</option> <option>菜单三</option> </select> <input type="button" onclick="getselectvalue()" value="弹出下拉列表的值" /> 加分咯!很辛苦的
其他:<select name="sel" dir="rtl" onchange="alert(this.value)">
<option>菜单一</option>
<option>菜单二</option>
<option>菜单三</option>
</select>

刚试过! document.getElementById("rtl").value
rtl 为Select 的id 

上一个:js如何取到后台传入的值
下一个:谁能帮我解释下这段js代码每行的意思?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,