lundi 22 août 2016

How to pass parameters from PHP file to Javascript

I have my file hotlaps.php where I have created a script of javascript with:

echo "<body onload="func1(".$array_1.",".$array_2.",".$array_3.");">";

In my file hotlaps.js I have that function:

function func1(array1, array2, array3){

    arr1 = array1;
    arr2 = array2;
    arr3 = array3;
    alert(piloto_array[0]);
    start();
}

But my variables arr1, arr2 and arr3 are undefined. Why?

Aucun commentaire:

Enregistrer un commentaire