javascript - Form Text Field becomes visible when dropdown-item is chosen -


i need text field inside form becomes visible when specified drop-down menu chosen. clear, text box becomes clear selecting specific drop-down menu, not submitting form. i.e., page 'listens' specific dropdown chosen , through methodology makes text field visible user fill in.

basic elements in form. easiest way use literal id's fields.

<form... >  <select id="choices"> <option id="choose_me" value="foobar">blah</option> <option id="whatever" value="whatever">blah</option> </select>  <input id="show_me" name="whatever" type="text" value="i hidden" style="display:none;" /> </form> 

i prefer jquery javascript needs:

//jquery $('#choices').live('change',function() {   if($('#choose_me').is(':selected'))   {     $('#show_me').show();   }   else   {     if($('#show_me').is(':visible'))     {       $('#show_me').hide();     }   } }); 

here's working example: http://jsbin.com/eculot/edit


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -