Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display The Text Box when one value is selected

Status
Not open for further replies.

Technos

Programmer
Mar 15, 2002
47
US
Hi,
I want to display the text box when a value"other" is selected from the combo box. Do I need to write Jscript? If yes How?

Here is my code...
<form method=post name=&quot;myForm&quot; id=&quot;myForm&quot;>
<select style=&quot;width:90%;&quot; id=&quot;subject1&quot; name=&quot;subject1&quot;>

<option selected>Select topic...</option>
<option value=&quot;security&quot;>Security</option>
<option value=&quot;Community&quot;>Change Community</option>
<option value=&quot;Memberships&quot; >Change Memberships</option>
<option value=&quot;Other&quot; >Other ...</option>
</select>

Here is my question

if option value = Other then only the following subject text field should be visible otherwise hidden.

<input id=subject name=subject value=&quot;&quot;>


Please Help :(( Thanks
 
This should work for you

<script language=javascript>
function ShowMe(theField)
{
if (theField.value==&quot;Other&quot;)
{document.form1.subject.style.display=&quot;&quot;
}
else
{document.form1.subject.style.display=&quot;none&quot;
}

}
</script>

<form method=post name=&quot;myForm&quot; id=&quot;myForm&quot;>
<select style=&quot;width:90%;&quot; id=&quot;subject1&quot; name=&quot;subject1&quot; onchange=&quot;ShowMe(this)&quot;>
<option selected>Select topic...</option>
<option value=&quot;security&quot;>Security</option>
<option value=&quot;Community&quot;>Change Community</option>
<option value=&quot;Memberships&quot; >Change Memberships</option>
<option value=&quot;Other&quot; >Other ...</option>
</select>

input id=subject name=subject value=&quot;&quot; style=&quot;display:none&quot;>
 
Hey SarkMan
Thanks a lot ... It worked...
You guys are cool.
I am pretty new to this field...hope to get same quick response from you in the future.(-:
 
hey SarkMan
Everything is working fine just there is one problem
When first time the page show up it gives the text field which should not display unless &quot;other&quot; is selected. But after this its perfect.
can you help? :(
 
Hey Its done by using OnFocus() ... cool %-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top