Forum Moderators: open

Message Too Old, No Replies

Dropdown difficulties

Dropdown list creating a text box

         

makkid

5:08 pm on Jan 4, 2005 (gmt 0)



Hi,

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

orion_rus

8:15 pm on Jan 4, 2005 (gmt 0)

10+ Year Member



) no problem at all) but u need to make a function
u can make it like so:

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>

orion_rus

8:21 pm on Jan 4, 2005 (gmt 0)

10+ Year Member



ups
u need to change
{document.getElementById('others').visibility="visible";}
to
{document.getElementById('others').style.visibility="visible";}