javascript - Selecting an option from one drop down populates other input fields -


i trying figure out how populate other tags specific text after selecting drop down.

so if drop down , drop down below following should happen. when choose "a" dropdown1, dropdown2 should populate "you chose a". if choose "b" dropdown2 should "you chose b". same goes "c"

here sample code below.

<html> <body> <form>   <select id="dropdown1">     <option value = "a">a</option>     <option value = "b">b</option>     <option value = "c">c</option>  </select>  <select id="dropdown2">     <option value="you chose a">you chose a</option>     <option value="you chose b">you chose b</option>     <option value="you chose c">you chose c</option> </select> </form>  </body>  </html> 

any appreciated. if show code awesome or if point me in right direction can find answer awesome to.

for predefined values have, can use following jquery/javascript code:

$(function() {     $('#dropdown1').change(function(){        $('#dropdown2').val('you chose ' + this.value);     }); }); 

js fiddle here: http://jsfiddle.net/vleong2332/82w7p0a6/

here example change dropdown1 when dropdown2 changes. http://jsfiddle.net/vleong2332/82w7p0a6/1/


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -