Reputation: 215
i am looking how to have it when i pick volvo option then the 740 is selected. i want to add other if statements but i cant not figure this out. if i pick saab i want it to select 240
I would like to use jquery or javascript
Thank you in advance. This is what i have and it does not work.
Below is the corrected code to change the drop downs.
<select id="myselect1">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<select id="myselectVolvo">
<option value="740">740</option>
<option value="940">940</option>
<option value="240">240</option>
<option value="340">340</option>
</select>
$('#myselect1').change(function(){
if($('#myselect1').val() == 'volvo'){
$('#myselectVolvo').val('940').trigger('change');}
else if($('#myselect1').val() == 'saab'){
$('#myselectVolvo').val('240').trigger('change'); }
//alert("The text has been changed.");}
//};
});
Upvotes: 0
Views: 52
Reputation: 303
You have a typo in the last js code line.
#myselctVolvo
should be #myselectVolvo
your condition in if is wrong you need to use $('#myselect1').val() == 'volvo'. You missed .val() after jquery selector.
Upvotes: 1