I do what I need to pass an array from my php to a function in external javascript. I am currently doing some tests that look like this:
<input type="text" onclick="show_error_message('<?php echo $array_sample ?>')" readonly="readonly">
and the javascript function is:
function show_error_message(test) { alert(test) }
my $ array_sample contains data that is array("1","2","3"); but the warning returned will be Array and whenever I change $array_sample to $array_sample[0] when passing parameters, I get data that is 1 as a warning. I wonder how I can pass the whole array to this to get the array in javascript as well. As you can see, I decided that this is a pop-up message for error handling, so I need it to be dynamic.
source share