My website currently has a dynamic AJAX script that updates a table based on the selection from a dropdown menu with the ID of [id="afl_player_ID"]
.
However, I am looking to extend this functionality so that the same script runs when either [id="afl_player_ID"]
or [id="afl_stat_ID"]
is changed.
How can I modify this code to achieve the desired behavior?
<script type="text/javascript">
jQuery(document).ready(function ($) {
var valueCheck;
jQuery("#afl_player_ID, #afl_stat_ID").on("change", function () {
player_ID = $("#afl_player_ID").val();
stat_ID = $("#afl_stat_ID").val();
jQuery.ajax({
type: "POST",
url: "/wp-admin/admin-ajax.php",
data: {
action: "call_advanced_player_basic_gamelog",
player_ID: player_ID,
stat_ID: stat_ID
},
success: function (output) {
jQuery("#advanced_player_basic_gamelog").html(output);
}
});
}).change();
});
</script>