...

View Full Version : How do I make a text field active on selection of a menu item?



alexander_c
02-27-2007, 11:27 AM
Can I use 'onclick' to activate a text field in the same form when user selects a particular item from a dropdown menu?

Thanks in advance,

Claire

mauzzzie
02-27-2007, 01:51 PM
What exactly are you trying to do? Can you be more specific please? Maybe an example?

alexander_c
02-27-2007, 02:19 PM
Hi there

I am trying to get the last option on my dropdown menu ('Other') to display the textfield 'chosencountry' by using 'onClick'

<select name="country" id="country">
<option value="" Option 1</option>
<option value="" Option 2</option>
<option value="" onClick="">Other</option>
</select>
<br>
<input type= "text" name="chosencountry" style="visibility:hidden">

Thanks in advance

Claire

mauzzzie
02-27-2007, 02:43 PM
I think this is what you are looking for:


<SCRIPT>
function checkIt(value){
if (value == "Other"){
document.getElementById("field").style.display = "";
}
}
</SCRIPT>
<SELECT name="country" id="country" onchange="checkIt(this.value);">
<OPTION value="">Option 1</OPTION>
<OPTION value="">Option 2</OPTION>
<OPTION value="Other">Other</OPTION>
</SELECT>
<BR>
<INPUT id="field" type="text" name="chosencountry" style="display:none;">

greetz

alexander_c
02-27-2007, 03:39 PM
Thanks a million.
That's exactly what I wanted!

I appreciate your time,

Claire



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum