By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

show textbox when dropdown value changed

P: 30
i write the code like this

Expand|Select|Wrap|Line Numbers
  1. function show()
  2. {
  3.    var subject=document.getElementById('<%=ddlsubject.ClientID %>');
  4. var txtsubject=document.getElementById('<%=TextBox1.ClientID%>');
  5. if(subject.value=="Other") 
  6.  
  7. txtsubject.style.display = '';
  8. txtsubject.focus();
  9. return false;
  10. return true;
  11. }
  12.  
  13.  
Expand|Select|Wrap|Line Numbers
  1. <asp:DropDownList id="ddlsubject" runat="server">
  2. <asp:ListItem Value="select">select</asp:ListItem>
  3. <asp:ListItem Value="computers">Other</asp:ListItem>
  4. <asp:ListItem Value="elctrical">Other</asp:ListItem>
  5. <asp:ListItem Value="Other">Other</asp:ListItem>
  6. </asp:DropDownList>
  7. <asp:TextBox ID="TextBox1" runat="server" Visible=false></asp:TextBox>
  8.  
in pageload

ddlsubject.Attributes.Add("onchange", "if(!show()){return false;};");
Feb 4 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Most likely the visibility is still false and you're setting the display property. If you add the line txtsubject.style.visibility = "visible", it should work.
Feb 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.