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>

Link to comment
Share on other sites

<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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.