I wrote a jQuery function that currently runs on Click Event. I need to change it so that it runs when a drop down box (Select- Option) value is changed. Here is my code:
<form id="form1" name="form1" method="post" action="">
<label>
<select name="otherCatches" id="otherCatches">
<option value="*">All</option>
</select>
</label>
</form>
$("#otherCatches").click(function() {
$.ajax({
url: "otherCatchesMap.php>",
success: function(msg) {
$("#results").html(msg);
}
});
});
Use change()
instead of click()
:
jQuery(document).ready(function(){
$("#otherCatches").change(function() {
$.ajax({
url: "otherCatchesMap.php>",
success: function(msg){
$("#results").html(msg);
}
});
});
});
http://api.jquery.com/change/
$(function() {
$("#otherCatches").change(function() {
$(this).val() // how to get the value of the selected item if you need it
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With