jquery - Javascript not working with form input and hiding options -


so trying pretty basic form, when when user selects , option shows more relative boxes under it. found things on here similar , can them work in jsfiddle can't them work on page. wondering doing wrong. in head have standard query link , link file. have tried putting script (with proper surrounding code) in head of file , still didn't work right.

my part 2 question is, want javascript in external file. script looks little different other ones have used in past, hoping on making external friendly.

<fieldset>  <form action="add_card.php" method="post">  <legend>test</legend>  parallel: <select name="parallel" id="parallel">   <option></option>   <option value="insert">insert</option>   <option value="base">base</option>   <option value="award">award</option>      </select>  <div id="insert" style="display:none;">        pack: <input type="string" name="pack" id="pack"></label>  </div>  <input type="submit" />  </form> </fieldset>     

and right external file looks this

$('#parallel').on('change',function(){     if( $(this).val()==="insert"){     $("#insert").show()     }     else{     $("#insert").hide()     } }); 

here working in jsfiddle, cut out that's not important right now. link

//edit had fix typo copying code 2 places.

try use change function instead

$('#parallel_test').change(function(){     if( $(this).val()=="insert"){         $("#insert_test").show()     }     else{         $("#insert_test").hide()     } }); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -