javascript - How to change the option item when I click on the fist option label? -
i'm setting 7 option item on webpage. how change option item when click on fist option label?
- (image of code)
- ■option1 a, b, c
- □option2 (a:10, b:20, c:30)
- □option3 (a:15, b:25, c:35)
- ...
□option7 (a:18, b:28, c:38)
(result)
- in case of choosing button of option1
- option2 ->10
- option3 ->15
- ...
- option7 ->18
(real codesample)
selection of a, b, c <select name="preset" id="saveaccount3" type="submit" value="option1" /> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> </select> <ul id="measureid"> <li><label for="creditcardmonth">option2</label> <select id="measureidsize1" name="measure1" class="chkselect"> <option value="10">10</option> <option value="20">20</option> <option value="30">30</option> </select></li> <li><label for="creditcardmonth">option3</label> <select id="measureidsize1" name="measure1" class="chkselect"> <option value="15">15</option> <option value="25">25</option> <option value="35">35</option> </select></li> <!-- abbreviation --> <li><label for="creditcardmonth">option7</label> <select id="measureidsize1" name="measure1" class="chkselect"> <option value="18">18</option> <option value="28">28</option> <option value="38">38</option> </select></li>
please have @ http://jsfiddle.net/z87qf/1/
$('#saveaccount3').change(function(){ var option = $("option:selected", this).val(); option == "a"? (opt=0) : (option == "b"? (opt=1): (opt=2)) $.each($('select[class=chkselect]'),function(i){ $('select[id=measureidsize'+i+'] option:eq('+opt+')').attr('selected', 'selected'); }); });
is requirement?
Comments
Post a Comment