Re: Creating a Window without JavaScript that is on top
| From: | Todd Cary | Date: | Thu, 23 Mar 2006 05:50:37 +0000 |
| Subject: | Re: Creating a Window without JavaScript that is on top | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-232436@lists.php.net to get a copy of this message | ||
How do I get the var into a php variable in the destination window?
Todd
Brady Mitchell wrote:
Personally, I think that posting a way to allow php to communicate with javascript OR any other language is relevant for a php-general list, don't you think?To use the value of a PHP variable in javascript, you create a javascript variable and then echo the value of the php variable. For example: Say you have a $price variable set in your PHP script and you want to use that in a JavaScript. <?php $price = 50; ?> <script language="javascript" type="text/javascript"> var price = <?php echo $price; ?>; </script> Assuming you put this in a .php file, PHP will parse the file and echo the price before the javascript makes it to the browser, so if you look at the source of the document you'll see: <script language="javascript" type="text/javascript"> var price = 50; </script> HTH, Brady