Results 1 to 5 of 5
Related
-
Javascript array in PHP Forum: PHP Forum
Replies: 0 -
PHP for automatically generating file/link list with file titles Forum: PHP Forum
Replies: 1 -
Adding values to an external .js Javascript file? Forum: Javascript Forum
Replies: 3 -
[SPLIT]passing values to an external .js file Forum: Javascript Forum
Replies: 37 -
passing values to an external .js file Forum: Javascript Forum
Replies: 10
-
09-15-2008, 10:36 AM #1
Passing PHP array from one file to Javascript array in another file
I am trying to pass a PHP array into a javascript array. The arrays will be in different files but the javascript file is referenced in the php file.
-
09-16-2008, 01:00 PM #2
Re: Passing PHP array from one file to Javascript array in another file
The way to do this will depend on what you are trying to do. Perhaps if you gave a few details, it would help.
-
12-27-2008, 11:22 PM #3
Re: Passing PHP array from one file to Javascript array in another file
No ways to pass php array to java script. You must generate page by using php, and write array to page like this
PHP Code:<script>
<?php
echo 'var list = array (';
foreach ($list as $key => $value) echo $key.' =>"'.$value.'"'."\n";
echo ');';
?>
</script>
-
12-29-2008, 12:52 AM #4
Re: Passing PHP array from one file to Javascript array in another file
Maldrex, you are both right and wrong. You are right in that you cannot directly pass a value from a PHP file to a Javascript page. However, if PHP is used to generate the HTML page (including the Javascript), the PHP values can easily be passed to the Javascript since the PHP creates the Javascript. You can therefore plug any value into the page you want.
So in answer to the original question, again:
The way to do this will depend on what you are trying to do. Perhaps if you gave a few details, it would help.
-
12-29-2008, 08:11 AM #5
Re: Passing PHP array from one file to Javascript array in another file
My example show TS how he can pass any array or variable from php script to JS, when you can include php script as out JS file or generate page on php. There is no anther ways to do what TS wont.
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum