jquery - Mulitlpe dropdowns with hidden textfields -
i'm trying have text field show when select "other" drop down. works fine, on first instance. need work on multiple occasions per page. have tried .each(), .foreach() can't seem find right place it. how function on multiple dropdowns
js:
$(window).load(function(){ $('#myselect').change(function() { if($(this).val() == 2) $('#txtdata').show(); else $('#txtdata').hide(); }); } )
html:
<select id="myselect"> <option value="" selected="selected">-select one-</option> <option value="no">no</option> <option value="2">yes</option> </select> <br /> <input type="text" id="txtdata" placeholder="please specify..." class="other" style="display:none;" />
i'm not sure trying see if helps you:
i switched code use class
, not id's
, created several input text each selectbox.
otherwise try being more specific please.
code:
$('.other').hide(); $('.sectos').change(function() { if($(this).val() == 3){ $(this).next('input').fadein(); } else{ $(this).next('input').fadeout(); } });
Comments
Post a Comment