Re: [PHP] Array Javascript

2002-09-05 Thread Justin French

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 an array make with a javascript.
 How can I read values with PHP from it?
 Kale.
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Array Javascript

2002-09-05 Thread Scott Houseman

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 ); $iSubscript++ )
{
// Add each member of the php array to the JS array
echo 'JSArray['.$iSubscript.'] = '.$Array[$iSubscript].';';
}
?

/SCRIPT

Regards

-|Scott


 -Original Message-
 From: kale [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, September 05, 2002 1:12 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Array Javascript 
 
 
 Hy,
 I have an array make with a javascript. 
 How can I read values with PHP from it?
 Kale.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Array Javascript

2002-09-05 Thread Marek Kilimajer

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


  



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Array Javascript

2002-09-05 Thread Marek Kilimajer

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?';
 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?
 Kale.


  





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Array Javascript

2002-09-05 Thread Marek Kilimajer

You have a JavaSript array on the client side, so you want to provide 
some click here link or button.
The whole thing will look like this:

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN

html

head

titleUntitled/title

script language=JavaScript

!--

var myArray;

var tmp,url,separator;

myArray = new Array('one','two','three');

function sendArray(){

url = 'http://site/script.php?';

while(tmp = myArray.shift()) {

   url += separator + 'phparray[]' + escape(tmp);

   separator = '';

}

document.location.href = url;

return false;

}

//--

/script

/head

body

a href= onClick=return sendArray()Click Here/a

/body

/html



kale wrote:

This is a javascript?
Where must I put this lines?
Thanks for help.
Kale.

-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, September 05, 2002 2:31 PM
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 with a javascript.
How can I read values with PHP from it?
Kale.


 





  



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Array Javascript?

2001-04-26 Thread Maxim Maletsky

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 Message-
From: Marcus Ouimet [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 27, 2001 6:58 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Array  Javascript?


I am trying to add a Javascript in array but it gives me an error
unless
certain characters are commented which makes sense, but then the Javascript
won't run. Any ideas here is what I am trying:

?
$info_box_contents = array();
$info_box_contents[] = array('align' = 'left',
 'text'  = '
A HREF=test.html onmouseover=document.images[0].src='test1'.jpg; return
true;
IMG SRC=images/reviews.jpg BORDER=0/A');

of course the ' characters are a problem etc. so for an example I tried:

?
$info_box_contents = array();
$info_box_contents[] = array('align' = 'left',
 'text'  = '
A HREF=test.html onmouseover=document.images[0].src=\'test1\'.jpg;
return true;
IMG SRC=images/reviews.jpg BORDER=0/A');

Any suggestions on how to get this to work?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]