Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:45 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.