All you can do is use PHP to print out Javascript code.

$data = "hello world";
<script language="javascript">
var something;
something = '<?=$data?>';

etc...It's no different than using PHP to print out HTML code.

Now, if you want to get that Javascript variable "something" sent back to
PHP, you have to assign it to a form element or tack it onto a URL.

---John Holmes...

----- Original Message -----
From: "Steve Buehler" <[EMAIL PROTECTED]>
Sent: Monday, April 29, 2002 11:29 AM
Subject: [PHP] javascript and PHP

> Does anybody know of a good/short tutorial about passing variables from
> JavaScript to/from PHP?  For example, how to do the following:
> <html>
> <head>
> <SCRIPT LANGUAGE="JavaScript">
> data = "hello world";
> </script>
> </head>
> <body>
> <?
> echo "$data<br>";
> ?>
> </body>
> </html>
> The above might at least give me a clue.  Just a note.  I really know
> nothing to speak of about JavaScript.
> Thanks in Advance
> Steve

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to