Can someone please tell me what's wrong with this code? Basically what I am doing is creating a php array for some GET variables. Then, I create a js array from that php array and pass it to a js function. The problem is that the function is not being called. I don't get to see the "hi" alert pop up.
<script type="text/javascript">
function change_values(js_array)
{
alert("hi");
}
</script>
<?php
$first_date_month = @$_GET["first_date_month"];
$last_date_month = @$_GET["last_date_month"];
$resume_date_month = @$_GET["resume_date_month"];
$pay_date_month = @$_GET["pay_date_month"];
$first_date_day = @$_GET["first_date_day"];
$last_date_day = @$_GET["last_date_day"];
$resume_date_day = @$_GET["resume_date_day"];
$pay_date_day = @$_GET["pay_date_day"];
$pay_time_hour = @$_GET["pay_time_hour"];
$pay_time_minutes = @$_GET["pay_time_minutes"];
$args = array($first_date_month, $first_date_day, $last_date_month, $last_date_day, $resume_date_month, $resume_date_day, $pay_date_month, $pay_date_day, $pay_time_hour, $pay_time_minutes);
print_r($args);
echo "<script language='text/javascript'>\n";
echo "var js_array = new Array();\n";
foreach($args as $key => $value)
echo "js_array[$key] = $value;\n";
echo "change_values(js_array)\n";
echo "</script>\n";
Some of the html source code that might be helpful to better understand what's going on.
<script type="text/javascript">
function change_values(js_array)
{
alert("ola");
}
</script>
Array
(
[0] => 3
[1] => 99
[2] => 99
[3] => 99
[4] => 99
[5] => 99
[6] => 99
[7] => 99
[8] => 99
[9] => 99
)
<script language='text/javascript'>
var js_array = new Array();
js_array[0] = 3;
js_array[1] = 99;
js_array[2] = 99;
js_array[3] = 99;
js_array[4] = 99;
js_array[5] = 99;
js_array[6] = 99;
js_array[7] = 99;
js_array[8] = 99;
js_array[9] = 99;
change_values(js_array);
</script>
Thanks in advance.