本文实例讲述了JS简单操作select和dropdownlist的方法。分享给大家供大家参考。具体实现方法如下:
一、js选中服务器控件select与dropdownlist
1. js操作服务器控件select
<script type=\"text/javascript\" language=\"javascript\">
function showMessage() {
if (document.getElementById(\"selectID\").options[document.getElementById(\"selectID\").selectedIndex].value == 1) {
alert(\"你好,你选择了第 1 个\");
document.getElementById(\"txtContractName\").setAttribute(\"enable\",false);
}
else if (document.getElementById(\"selectID\").options[document.getElementById(\"selectID\").selectedIndex].value == 2) {
alert(\"你好,你选择了第 2 个\");
}
}
</script>
//js操作服务器控件dropdownlist
<asp:DropDownList ID=\"ddlFolder\" runat=\"server\" SkinID=\"ddlSkin\" AutoPostBack=\"false\" OnSelectedIndexChanged=\"ddlFolder_SelectedIndexChanged\">
<asp:ListItem Value=\"0\">选项0</asp:ListItem>
<asp:ListItem Value=\"1\">选项1</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID=\"ddlFolder\" runat=\"server\" SkinID=\"ddlSkin\" AutoPostBack=\"false\" OnSelectedIndexChanged=\"ddlFolder_SelectedIndexChanged\">
<asp:ListItem Value=\"0\">选项0</asp:ListItem>
<asp:ListItem Value=\"1\">选项1</asp:ListItem>
</asp:DropDownList>
本文地址:https://www.stayed.cn/item/1711
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我