Jump to content

PHP variable into javascript


idy

Recommended Posts

you are mixing js and php there buddy!

PHP will stop running once the page has been served to the client - php can do no more after that until the next request is sent.

you wil have to populate and array explicitly in js usign the php array you have constructed and then use id to traverse it.
Actually the variable $array is already used in my PHP script before writing the JS function.
If I write :
[code]
var result = '<? echo $array[0]; ?>';
[/code]
I do have the content of $array[0] into result.
The only thing I am trying to do is to retrieve the JS variable id instead of the hard-coded value 0 into $array. Or is still the same problem ? Thanks !

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.