I inherited some javascript code. One of them is a function chg(x) which reloads the page after a drop down list's value has been changed.
How do I use jquery to change the drop down list's value and call chg(x) when the value is changed ?
I inherited some javascript code. One of them is a function chg(x) which reloads the page after a drop down list's value has been changed.
How do I use jquery to change the drop down list's value and call chg(x) when the value is changed ?
Use the .change method:
$('#myDropdownID').change(function() {
$(this).val('some value'); //will change the dropdown's selected value to whatever you want
chg(x);
});
Assuming that the chg() function is somewhere in the code.
More references here: .change() jquery method