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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement using CSS

Status
Not open for further replies.

bongmarley

Programmer
Oct 21, 2002
74
CA
I have a textbox that i want to be visible or invisible depending on what is selected in a select box. If 1 in selected then textbox is hidden. If 2 sellected the textbox is visible. How do I go about this?
 
Try this:

<html>
<head>
</head>

<body>
<script language=&quot;javascript&quot;>

function HideUnhideButton(TheValue)
{
if (TheValue == 'Option1')
document.MyForm4.MyText4.style.visibility = 'hidden';
else
document.MyForm4.MyText4.style.visibility = 'visible';
}
</script>

<form name=&quot;MyForm4&quot;>
<SELECT name=&quot;selectboxname&quot; ONCHANGE=&quot;HideUnhideButton(selectboxname.options[selectboxname.selectedIndex].value);&quot; SIZE=&quot;1&quot;>
<OPTION value=&quot;none&quot; selected>- Select an option -</OPTION>
<OPTION value=&quot;Option1&quot;>Option 1 (hidden)</OPTION>
<OPTION value=&quot;Option2&quot;>Option 2 (visible)</OPTION>
</SELECT>
<br><br>
<input style=&quot;visibility:hidden&quot; TYPE=&quot;text&quot; NAME=&quot;MyText4&quot;>
</form>

</body>
</html>

Hope this helps,
Erik <-- My sport: Boomerang throwing !!
!! Many Happy Returns !! -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top