hi everyone,
I am in problem to get the array data from php to use it in js.


I want to use those data in js.

Can anyone help me ??

9 Years
Discussion Span
Last Post by adorosh
echo "
<script type=\"text/javascript\">
function test(){
<body onload=\"javascript: test();\">

This is how you can use php variables in your javascript. This is just an example.


thank you for your helping,but I need to first check the data ,If data exists then run the js code otherwise not.
this like:
first : read data from database .
second : check the data
third : if data exists then run js otherwise not.

i do it in the same file.but I want to simplify my code ,so I need to place the js code in the other file.
i just need if their have any possibility to get the array data of php in js.


You can get the JS script into some other file, but make this script use some global variable.
By this way you can parse needed array in PHP, then put the value on page and if the JS script included will find those, it will run.
It's hard code, but will work.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.