Jump to content

[SOLVED] Showing Hidden text box when condition is met


roberts78

Recommended Posts

I have a form that has a dropdown menu. I cant figure out how to set a condition so that when 'Other' is checked it displays a hidden text box to fill out. But when any other selection is chosen it does not show it. Any ideas and Thanks again.

 

 

<OPTION VALUE="0" SELECTED>--- Please Select ---</OPTION>

<OPTION VALUE="1">Option 1</OPTION>

<OPTION VALUE="2">Option 2</OPTION>

<OPTION VALUE="3">Option 3</OPTION>

<OPTION VALUE="4">Other</OPTION>

<html>
<head>
<script type="text/javascript">

function showField(fieldID, showBool)
{
  document.getElementById(fieldID).style.visibility = (showBool) ? '' : 'hidden';
}

</script>
</head>

<body>
<select name="something" onchange="showField('other', this.value=='4');">
<option value="0" selected="selected">--- Please Select ---</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">Other</option>
</select><br />
<input type="text" name="other" id="other" style="visibility:hidden;" />
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.