开发者

On text-box length greater then zero clear listbox and disable

Is it possible in java script that when a text box control is populated that it clears my list box and disables it and visa versa. I'm using ASP.net C# to bind the list box.

<asp:TextBox ID="_tx_Zip" On??? runat="server" Width="197px"></asp:TextBox>

<asp:ListBox ID="_lb_Zip" runat="server" Height="82px" SelectionMode="Multiple" Width="200px">

I was messing around with the OnTextChanged event but that's no good. Sorry I'm tryin开发者_StackOverflow中文版g to learn java script.


You can use onblur event of javascript and do like...

<asp:TextBox ID="_tx_Zip" onblur="update();"

 function update() {
        if (document.getElementById('<%=_tx_Zip.ClientID %>').value != '') {
            document.getElementById('<%=_lb_Zip.ClientID %>').disabled = true;
            document.getElementById("<%= _lb_Zip.clientID %>").options.length = 0;
        }
        else {
            document.getElementById('<%=_lb_Zip.ClientID %>').disabled = false;
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜