0

i have 2 dropdown menus,one is with a list of car names and another one is with list of number.if i select the any one of the car names from 1st ddl the second one should show the corresponding number related to the selection.

<form method="post" action="sample2.jsp">
<select name="sel1">
<option value="Alto">Alto</option>
<option value="Esteem">Esteem</option>
<option value="Honda City">Honda City</option>
<option value="Chevrolet">Chevrolet</option>
</select>
<br>
<select name="sel2">
<option value="1.1">1.1</option>
<option value="1.2">1.2</option>
<option value="1.3">1.3</option>
<option value="1.4">1.4</option>
</select>
<input type="Submit" value="Submit">
</form>

example: alto->1.1

ksa
  • 311
  • 1
  • 10
  • 29

1 Answers1

0

You could it with jQuery as below:

$('#sel1').change(function(){    
    var index = $('#sel1').attr('selectedIndex');
    $('#sel2').attr('selectedIndex', index);        
});

See example at: http://jsfiddle.net/a2crA/1/

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dilini Rajapaksha
  • 2,610
  • 4
  • 30
  • 41