我有一個文本框和下拉項目All, abc, etc
。我希望javascript代碼在全部選中時禁用文本框,並在選擇其他選項時啓用它。
我使用該代碼解決了這個問題,但問題是,如果發佈表單,即使選擇了abc或其他任何內容,文本框也會被禁用。文本框禁用回發
<script type="text/javascript">
function changeddl() {
document.getElementById("txtsearch").disabled = document.getElementById("ddlcolumn").value == "All";
}
</script>
ASPX
<asp:DropDownList ID="ddlcolumn" runat="server" CssClass="ddl" Width="120px" AppendDataBoundItems="true" ClientIDMode="Static" ValidationGroup="Search" onchange="changeddl();" >
<asp:ListItem>All</asp:ListItem>
<asp:ListItem>abc</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="txtsearch" runat="server" CssClass="txt" Width="200px"
ValidationGroup="Search" ClientIDMode="Static" SkinID="txt"></asp:TextBox>