I am storing some functions in an object, and these functions need to be accessed in PHP via the onclick attribute of the dynamic button. Normally, this would be very simple if the functions were not stored in an object, but unfortunately, this is how these functions need to be created:
var arrayLength = <?php echo $arrayLength; ?>;
var click = {};
for (var num=1;num<=arrayLength;num++) {
var newClick = "click_" + num;
click[newClick] = function() {
// some contents when this button is clicked
};
}
To call them in javascript, I'd do something like:
click['click_' + someID]();
However, since I'm working with PHP, I am not so sure how I will be able to call this in the onclick attribute. It is something I really need to do, so if you know a solution or can think of a workaround, let me know.