I have set a couple of global variables on page load as follows:
jQuery(document).ready(function() {
console.log("Onload PHP vis_options:"+JSON.stringify(<?php echo
json_encode($vis_options); ?>)+"\r\n");
var vis_options = <?php echo json_encode($vis_options); ?>;
var home_options = <?php echo json_encode($home_options); ?>;
console.log("Onchange PHP vis_options:"+JSON.stringify(vis_options)+"\r\n");
var ind_pts_game = Number(jQuery("#ind_pts_game").val());
jQuery(document.body).on("change", '#bowl1v, #bowl2v, #bowl3v, #bowl4v, #bowl1h, #bowl2h, #bowl3h, #bowl4h', function(e) {
console.log("ind_pts_game:"+ind_pts_game+"\r\n")
console.log("Onchange PHP vis_options:"+JSON.stringify(vis_options)+"\r\n");
console.log("Onchange PHP home_options:"+JSON.stringify(home_options)+"\r\n");
return;
});
});
When changing one of the ids in the onchange function, the ind_pts_game
will display in the console. However, the vis_options
& hope_options
report as undefined
.
Any insight on how to pass these correctly would be appreciated. They do display properly on page load, just not within the change function.