Forum Moderators: open
I'm trying to create a form on a webpage but it is really annoying me how to tackle one particullar problem. I have a dropdown list of items, what I need is that when the user selects a particullar item (eg. Other) a text box appears letting the user type anything he/she likes..
Here's what I have
<select name="test>
<option>Football</option>
<option>Basketball</option>
<option>Other</option>
</select>
Now what I need, is that when the user selects "Other", a text box appears letting them type something else, it would also be nice if it disappeared when de-selecting "Other" too.
I can get the form to work but I have to have the text box on display constantly.
Please help if you can.
Mark
function HideShowTextBox(d)
{if (d.options[d.selectedIndex].innerHTML=="Others")
{document.getElementById('others').visibility="visible";}
else {document.getElementById('others').visibility="hidden";}
}
----
<body>
<select onchange="HideShowTextBox(this)" >
<option>....</option>
<option>....</option>
</select>
<input type="text" id="others" />
</body>