<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" οnclick="aa();" /> </div>
</form>
</body>
</html>
JS读取DropDownList中的值
最新推荐文章于 2022-03-25 08:34:16 发布