用JS获取DropDownList选中得值

时间:2023-12-04 22:23:38

HTML:

 <asp:DropDownList ID="DropdownList1" runat="server" AutoPostBack="true" />

JS:

 <script type="text/JavaScript">
function getvalue(){ var select1 = document.all.<%= DropdownList1.ClientID %>;
var selectvalue = select1.options[select1.selectedIndex].value;
var selectText= select1.options[select1.selectedIndex].text;
alert(selectvalue+" "+selectText);
}
</script>