Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
| Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 15th, 2007, 08:32 AM
Authorized User
 
Join Date: Sep 2006
Location: , Kerala, India.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to aneesh_sunu@yahoo.co.in Send a message via Yahoo to aneesh_sunu@yahoo.co.in
Default How can I pass a variable from php to Javascrip

Hi
How can I pass a variable from php to Javascript
Is it possible
__________________
Regards
Aneesh
 
Old May 15th, 2007, 09:07 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

There may be a better way, but what I have always done is...

echo "<script language='javacript'>var myVar=0;</script>";

Mike
EchoVue.com
 
Old May 17th, 2007, 06:50 AM
Friend of Wrox
 
Join Date: Nov 2005
Location: Rotterdam, , Netherlands.
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I usually like to use as little code as possible by using short tags some will say that short tags should be avoided but i find it to my liking here is how I normally do it.
Code:
<script language='javacript'>var myVar=<?=$phpVar?></script>
__________________________________________________ ________
I am DJ Kat...that's my name. Its a D and a J and a Kat with a K.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass Value to XSLT variable bonekrusher XSLT 3 October 9th, 2006 10:16 AM
pass java variable to xsl variable kathy1016cats XSLT 1 June 14th, 2006 06:23 PM
pass the result of a query to a variable ... eusebio Pro VB Databases 6 March 30th, 2006 07:41 PM
pass variable kapi.goel C# 1 January 6th, 2006 05:54 AM
pass form elements variable vickyj Classic ASP Basics 0 October 29th, 2005 04:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.