Re: pass. vars. betn. javascript and php
| From: | 1LT John W. Holmes | Date: | Mon, 06 May 2002 18:03:49 +0000 |
| Subject: | Re: pass. vars. betn. javascript and php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96289@lists.php.net to get a copy of this message | ||
> 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...