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 ??

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.