Click here to Skip to main content
15,942,964 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am trying to show or hide textbox based on drop down list selected value.

When selected value will be "Other" then textbox will be visible.

Here is my javascript code:

$("#gridhvac input[name$='ddlhvacmake_rev']").change(function () {
           if (this.value == "Other") {
               $("#gridhvac input[name$='txtother_rev']").attr("style","display: block;");
           else {
               $("#gridhvac input[name$='txtother_rev']").attr("style", "display: none;");

and here is aspx code:

<asp:TemplateField HeaderText="MAKE">
        <asp:DropDownList ID="ddlhvacmake" runat="server">
<br />
        <asp:TextBox runat="server" ID="txtother" Style="display: none;"/>
        <asp:Label ID="lblhvacmake" runat="server" Text='<%#Eval("MAKE") %>'/>
                <asp:DropDownList ID="ddlhvacmake_rev" runat="server">
                <br />
                <asp:TextBox runat="server" ID="txtother_rev" Style="display: none;"/>

I cannot figure out what's wrong in this code. This does not work and there is no error also.
Andy Lanng 16-Sep-15 4:03am    
Have you stepped through the javascript? I use chrome but firebug for firefox isn't bad. You can set breakpoints and check the values of your variables. That might help you find the issue
planetz 16-Sep-15 5:43am    
I'll follow your suggestion Andy...
planetz 16-Sep-15 6:34am    
Well it says object expected...any idea what object can be missing??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900