php links and javascript

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

php links and javascript

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

place it somewhere php can get hold of it, like in a cookie, the url, or post data.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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.
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post 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?)
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post 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?
Last edited by chrys on Wed Oct 12, 2005 9:36 am, edited 1 time in total.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post 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?)]
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post 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>
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post 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?
Post Reply