You can't. Javascript happens on the client side AFFTER PHP has happend on
the server side. For PHP to ready variables made with javascrip,t you'd
have to submit those variables/arrays via POST of GET to the PHP file.
Justin
on 05/09/02 9:11 PM, kale ([EMAIL PROTECTED]) wrote:
Hy,
I have
Hi
To Assign values from an array in PHP to JavaScript,
you could try something like this.
$Array = array( 'one', 'two', 'three' );
Now in your JavaScript:
SCRIPT LANGUAGE=JavaScript
JSArray = new Array(?= sizeof( $Array )?);
?php
for ( $iSubscript = 0; $iSubscript sizeof( $Array );
var tmp,url;
url = 'http://site/script.php?';
while(tmp = myArray.shift()) {
url += 'phparray[]' + escape(tmp);
}
document.location.href = url;
In script.php, you'll find array named phparray
kale wrote:
Hy,
I have an array make with a javascript.
How can I read values with PHP from it?
I forgot , the right version:
var tmp,url,separator;
url = 'http://site/script.php?';
while(tmp = myArray.shift()) {
url += separator + 'phparray[]' + escape(tmp);
separator = '';
}
document.location.href = url;
Marek Kilimajer wrote:
var tmp,url;
url = 'http://site/script.php?';
To: PHP
Subject: Re: [PHP] Array Javascript
var tmp,url;
url = 'http://site/script.php?';
while(tmp = myArray.shift()) {
url += 'phparray[]' + escape(tmp);
}
document.location.href = url;
In script.php, you'll find array named phparray
kale wrote:
Hy,
I have an array make
STRIPSLASHES();
use single quotes for the array.
add the slashes in front each JS's single quote,
when echoing use :
echo stripslashes($js);
Sincerely,
Maxim Maletsky
Founder, Chief Developer
PHPBeginner.com (Where PHP Begins)
[EMAIL PROTECTED]
www.phpbeginner.com
-Original
6 matches
Mail list logo