Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need the textbox to appear when option other is selected from dropdown my code is give below its not working plzz help me


XML
<asp:DropDownList ID="DdlOccupation" runat="server" class="select03" Height="25px" OnSelectedIndexChanged="if(this.value=='OTHERS'){this.form['other'].style.visible='true'}else{this.form['other'].style.visible='false'};"
                       Width="150px">
                       <asp:ListItem Value="Select">Select</asp:ListItem>
                       <asp:ListItem Value="1">BUSINESS</asp:ListItem>
                       <asp:ListItem Value="2">FARMER</asp:ListItem>
                       <asp:ListItem Value="3">HOUSEWIFE</asp:ListItem>
                       <asp:ListItem Value="4">RETIRED</asp:ListItem>
                       <asp:ListItem Value="5">SERVICE</asp:ListItem>
                       <asp:ListItem Value="6">STUDENT</asp:ListItem>
                       <asp:ListItem Value="7">OTHERS</asp:ListItem>
                   </asp:DropDownList>

XML
<td>
                    <asp:TextBox ID="txtOther" Autocomplete="off" size="20" Height="25" class="incl" width="150px" runat="server" Visible="false"></asp:TextBox>
                </td>
Posted
Updated 28-Nov-13 0:11am
v2

Hi,

You textbox id has different value(txtOther) other than mentioned in the script.
Try to change this.form['other'] to this.form['txtOther']

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
Comments
Member 10310320 28-Nov-13 6:37am    
I did it not working.
♥…ЯҠ…♥ 28-Nov-13 6:39am    
Write the inline script to function inside script tag and try to call the function in indexchanged event.Are you sure script is working fine?
Member 10310320 28-Nov-13 7:37am    
No i am not sure about script , if there is any other way to do this then help me
XML
<script type="text/javascript">
    $(document).ready(function () {

        $('#<%=DdlOccupation.ClientID%>').change(function () {


            if ($(this).val() == '7') {
                $('#<%=txtOther.ClientID%>').show();

            }
            else {
                $('#<%=txtOther.ClientID%>').hide();
            }

            // $('#<%=txtDOB.ClientID%>').datepicker();
        });
    });



    </script>
 
Share this answer
 

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