Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Retrieval of javascript variables in href
Old 06-16-2008, 02:02 PM PHP Retrieval of javascript variables in href
Average Talker

Posts: 19
Name: Meir Ech
Trades: 0
I want to open a new php page from a javascript
- using this line of code:

location.href="newpage.php?totX=results[0]&totY=results[1]&totZ=results[2]";

Tried retrieving these results
with something like this:

echo $_GET['totX'];
echo $_GET['totY']; ...


- But instead of displaying values,
I'm displaying
-> results[0]
-> results[1]
etc.

How do I grab hold of the values within
these variables?
(On the javascript side I'm sure I'm sending the right values
because I checked them with "alert" just before they were sent.)
ruffy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-16-2008, 02:53 PM Re: PHP Retrieval of javascript variables in href
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Code:
location.href="newpage.php?totX="+results[0]+"&totY="+results[1]+"&totZ="+results[2];
You have gave a string, not a variable name. You need to concatenate the variables content, not their names if you want to retrieve their content
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-16-2008, 03:32 PM Re: PHP Retrieval of javascript variables in href
Average Talker

Posts: 19
Name: Meir Ech
Trades: 0
Comment s'a va, tripy?

It's confusing because
PHP seems to understand that
totX, totY and totZ are variables
because it echoes their corresponding names correctly.

For example, it knows that
$_GET['totY'] corresponds to results[1].
It seems to understand the meaning of the equal sign ("=") in the href!

May I ask you, s'il vous plait,
if results[0] were 52, and
results[1] were 53 and
results[2] were 54
- on the javascript side,
what could I do in PHP to get these?
Merci, mon ami.
ruffy is offline
Reply With Quote
View Public Profile
 
Old 06-16-2008, 03:44 PM Re: PHP Retrieval of javascript variables in href
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
If you read tripy's response again, you'll see that he has already answered your question. The GET query ?totX=results[0]&totY=results[1]&totZ=results[2] returns result[0], result[1], result[2], because the variables $_GET['totX'], $_GET['totY'], and $_GET['totZ'] are being assigned the values 'result[0]', 'result[1]', and 'result[2]'. Javascript, unlike PHP, always requires concatenation if you wish to mix strings with variables.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 06-16-2008 at 03:48 PM..
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 06-16-2008, 03:52 PM Re: PHP Retrieval of javascript variables in href
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Salut Ruffy !
Again, with a coloration to show you the differences:

location.href="newpage.php?totX="+results[0]+"&totY="+results[1]+"&totZ="+results[2];

There, it should be more visible now...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-16-2008, 06:22 PM Re: PHP Retrieval of javascript variables in href
Average Talker

Posts: 19
Name: Meir Ech
Trades: 0
Thanks gentlemen. I now get it.
G-d bless you good people of the world
(those "in the void" and "wayfarers" included).
ruffy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Retrieval of javascript variables in href
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17464 seconds with 12 queries