Page 1 of 1
php links and javascript
Posted: Wed Oct 12, 2005 8:09 am
by sebs
Is there anyway I can give this value(in javascript) to a php variable:
document.MM_returnValue;
I need to put the value of a link in a $_SESSION['something'],any other ideas?
Posted: Wed Oct 12, 2005 8:12 am
by feyd
place it somewhere php can get hold of it, like in a cookie, the url, or post data.
Posted: Wed Oct 12, 2005 8:13 am
by Grim...
I did it ages ago, and the only way I found of doing it was to have the JScript open a new page called 'page.php?jscriptvalue=[whatever]', then use php to get the value.
Posted: Wed Oct 12, 2005 8:20 am
by sebs
how can I carry information across pages. User A makes a choice on one page and then goes to another. How can I "remember" what his or her choice was?The names are already outputed in different links and I need to know the variable on which has been clicked on.
Do you have an example of how to transmit variables in javascript,the value is in <a href=... name="cf" >
'page.php?jscriptvalue=[whatever]'(could you be more dpecific with this?)
Posted: Wed Oct 12, 2005 9:17 am
by chrys
Look into AJAX programming, or more specifically, XMLHttpRequest. It's GOD!
edit: removed this link because for some reason my script has been reverted to an ancient version that doesn't use AJAX. wtf host?
Posted: Wed Oct 12, 2005 9:28 am
by shiznatix
use either:
GET - probably going to be your best bet for this
POST
SESSION - maybe your best bet but who knows
COOKIE
that is how you can share data between pages.
Posted: Wed Oct 12, 2005 9:46 am
by sebs
I know I have to use GET just that I don't know how to transmit the document value in jscriptvalue:
page.php?jscriptvalue=[what is here?(cf.value?)]
Posted: Wed Oct 12, 2005 1:05 pm
by chrys
sebs wrote:I know I have to use GET just that I don't know how to transmit the document value in jscriptvalue:
page.php?jscriptvalue=[what is here?(cf.value?)]
You don't want to use href... do this:
<a href="#" onClick="document.location.href='page.php?jscal='+jsval">Link</a>
Posted: Thu Oct 13, 2005 2:15 am
by sebs
But if I write <a href="#" ....> sends me to the first page.What should I write so href doesn't count,only onclick?