[PHP] pass. vars. betn. javascript and php

2002-05-06 Thread Pushkar Pradhan

Is it possible to pass variables from a php page to a page using
javascript, and vice versa,
I've the variable - an array passed in the url of the page.

-Pushkar S. Pradhan


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




Re: [PHP] pass. vars. betn. javascript and php

2002-05-06 Thread 1LT John W. Holmes

 Is it possible to pass variables from a php page to a page using
 javascript, and vice versa,
 I've the variable - an array passed in the url of the page.

You can use PHP to write HTML or Javascript. You can submit data to PHP
through GET, POST, COOKIE, values. Those are your options.

So, if you have a PHP variable, that you want to pass to Javascript, then
you do this.

? $my_php_var = foo; ?
script language='javascript'
my_js_var = '?=$my_php_var?';
/script

Now, to get your JS variable back to PHP, you have to include it in a form,
or tack it on to a URL. You can put it in a form as a hidden element.

Hope that helps,

---John Holmes...


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




Re: [PHP] pass. vars. betn. javascript and php

2002-05-06 Thread Kevin Stone

Unless you're doing HTML as a halfway between Javascript and PHP, you cannot
do a POST method (obviously).  But you can always pass values in the URL
string.

Access the URL string in Javascript with document.location.search.  Access
the URL string in PHP with $HTTP_GET_VARS or $_GET.  You can generate a
URL with variables then do a Header redirect to automate the switch.  Use
document.location.href in Javascript and header('Location:') in PHP.

Read up on these methods and you should be all set.

-Kevin

- Original Message -
From: Pushkar Pradhan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 06, 2002 11:01 AM
Subject: [PHP] pass. vars. betn. javascript and php


 Is it possible to pass variables from a php page to a page using
 javascript, and vice versa,
 I've the variable - an array passed in the url of the page.

 -Pushkar S. Pradhan


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