I have this in html code:
<select name="t" id="t">
<option value="6">test2</option>
<option value="0">Overall</option></select>
<select name="m" id="m">
<option value="9">something to change</option>
<option value="0">back to Overall</option></select>
<div id="main"></div>
I would like change automatically Select “t” to Value “0” when user change Value of Select “m” to “0”. So I have a jQuery script:
$(function(){
$('#m, #t').change(function(){
if($('#m').val() == '0') {
$('#t').val('0').change();
$("<div>succes!</div>").appendTo("div#main"); }
});
});
But this script working only partialy. Script doesn’t display the information “succes!” after changing Select. Why?
Also you can see this here: http://jsfiddle.net/SQvua/
You need to remove the
.change()part from this:There’s no “change” plugin so as it stands it results in a runtime error and the rest of the code does not get executed.
Updated fiddle.