JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 6th, 2001, 09:35 PM
CyberN8 CyberN8 is offline
UberGeek
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 67 CyberN8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 50 m 48 sec
Reputation Power: 13
Question Setting PHP variables with Javascript?

Is there a way to set a PHP variable with javascript? I'd like to do something like this:

<SCRIPT LANGUAGE='Javascript'>
<!--
function set_fruit( fruit )
{
$this_fruit = fruit;
return true;
}
//-->
</SCRIPT>

<A HREF="www.foo.com" onClick='set_fruit( "Apple" );'>
Apple</A>


where $this_fruit is a PHP session variable.

Reply With Quote
  #2  
Old August 6th, 2001, 11:02 PM
sano sano is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Redmond, WA
Posts: 218 sano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
No. You can't do that. You can use PHP to set a Javascript variable but it can't be done the other way around.

Reply With Quote
  #3  
Old August 6th, 2001, 11:49 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
Hi Sano, I'm going to be a pain in the neck and contradict you again, sorry .

Yes, you can do it, if you follow the (somewhat contorted) methods discussed in this thread: http://forums.devshed.com/showthrea...16326&forumid=5

Sano is technically right. PHP and Javascript can't directly interact, but if you use the HTTP mechanisms available in the right way, you can accomplish your goal in a way that is fairly seamless to the end-user. See our lively discussion about this topic at http://forums.devshed.com/showthrea...ight=javascript

HTH
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
  #4  
Old August 7th, 2001, 04:33 AM
sano sano is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Redmond, WA
Posts: 218 sano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
I knew you'd pop up somewhere!

At least you acknowledged I was technically right

Reply With Quote
  #5  
Old August 7th, 2001, 09:43 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
What do you mean "at least"? (lol)

Reply With Quote
  #6  
Old August 7th, 2001, 11:48 AM
CyberN8 CyberN8 is offline
UberGeek
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 67 CyberN8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 50 m 48 sec
Reputation Power: 13
Talking

Thanks guys!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Setting PHP variables with Javascript?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap