javascript - Put an option value in a input text -


i'm trying put option value of select in input text have this:

 <select name="typers" id="contact-location" class="form-control">      <option value="facebook">facebook</option>      <option value="twitter">twitter</option>      <option value="google +">google +</option>      <option value="autres">autre</option> </select> 

and when submit, want input text value of option selected :

 <input type="text" name="typers" value="myselectedoption"/> 

i have tried without success... know how ?

you can use:

$('input[name=typers]').val($('#contact-location').val()); 

working demo on select change


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -