Page 1 of 1

Use javascript varibles with PHP (This is an emergency)

Posted: Tue Jan 31, 2006 2:51 am
by aetoc
I have to user a varible from javascript with PHP.

Can any one help me?

Posted: Tue Jan 31, 2006 3:06 am
by pleigh
i thought im not that specific but you are more not too specific pal...

you said
aetoc wrote:What do you want to do?

Give me some help so I can celp you.
hey, want someone to help you? wait patiently...i don't need your help if you are asking for exchange. :wink:

Posted: Tue Jan 31, 2006 3:20 am
by Chris Corbyn
It's been asked lots. Searching this forum (and Google) would have revealed that there are two ways to do it.

AJAX is the new preferred method.
Using window.location along with $_GET is the old-style way to do it.

Code: Select all

var x = 42;
window.location='some_php_script.php?x='+x;
some_php_script.php

Code: Select all

<?php echo $_GET['x']; ?>

Posted: Tue Jan 31, 2006 3:41 am
by aetoc
sorry but I'm little confuse.

I want to save the window.source in a var from the page a and send it to page b.

can this help you.

Posted: Tue Jan 31, 2006 7:49 am
by Chris Corbyn
aetoc wrote:sorry but I'm little confuse.

I want to save the window.source in a var from the page a and send it to page b.

can this help you.
It's probably too long a string for a URL, in which case you definitely need AJAX but anyway:

Code: Select all

window.location = 'some_script.php?source=' + window.source;
If you want to use AJAX but don't wish to learn much about how it works try something like XAJAX

http://xajax.sourceforge.net/