JS读取DropDownList中的值

来源:互联网 发布:网络摄像头接线图解 编辑:程序博客网 时间:2024/06/03 19:14
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>无标题页 </title>     <script type="text/javascript">     function aa()     {         var ddl = document.getElementById("DropDownList1");         alert(ddl.selectedIndex);//选择索引值         alert(ddl.options[ddl.selectedIndex].value);//绑定值         alert(ddl.options[ddl.selectedIndex].text);//文本值     }     </script> </head> <body>     <form id="form1" runat="server">     <div>         <asp:DropDownList ID="DropDownList1" runat="server">             <asp:ListItem Value="1">一 </asp:ListItem>             <asp:ListItem Value="2">二 </asp:ListItem>             <asp:ListItem Value="3">三 </asp:ListItem>         </asp:DropDownList>         <input id="Button1" style="position: relative" type="button" value="button" onclick="aa();" /> </div>     </form> </body> </html>

0 0