Current location: Hot Scripts Forums » General Web Coding » JavaScript » Passing a PHP variable in Javascript???


Passing a PHP variable in Javascript???

Reply
  #1 (permalink)  
Old 01-04-05, 02:32 PM
todayscoffee todayscoffee is offline
Newbie Coder
 
Join Date: Oct 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Passing a PHP variable in Javascript???

Hi all i'm posting this question both PHP and Javscript forums in hopes that someone will have the solution.

Here's the deal:
I have a drop down style menu that i'm using, that's written in js and i want to use a php variable within it:
Ex:
Code:
var pmLink10 = new PopMenu('Link','','a','page.php?user=$user','Go to this page');
$user is the variable that i want to pass through it but i'm not sure how or if there a way to declare it as php within the exsisiting js code or should i take another route?

Thanks
__________________
One may say "They're losing their marbles." I would ask, "Who gave them the marbles in the first place?"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-06-05, 04:00 AM
4thorder's Avatar
4thorder 4thorder is offline
Newbie Coder
 
Join Date: Dec 2004
Location: USA MI
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
please

place the dropdown code on here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-08-05, 10:45 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
All you really have to do is something like this
Code:
echo "var pmLink10 = new PopMenu('Link','','a','page.php?user=$user ','Go to this page');"
When printing out the script on the page.
The script will have no idea that the 'page.php?user=$user ' string contains a variable since $user has been replaced with its value before the script is parsed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
execute php into javascript function Hagoromo PHP 3 05-23-07 03:19 AM
Need Help In PHP Programming for a single code suggestion !! CyberRomeo PHP 1 11-27-04 11:38 AM
javascript and php clashes, need expert help nassau JavaScript 2 11-12-04 08:19 AM
javascript multiple select menu for php? isaacmlee JavaScript 1 10-15-04 10:53 AM
javascript variable passed to JSP workaround! peejay Everything Java 0 08-05-04 01:41 AM


All times are GMT -5. The time now is 12:33 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.