-2

Possible Duplicate:
Ajax, javascript send variable to another page, on click

Hello, Lets say i have 3 divs:

<div id="section1">
<? $var='value1'; ?>
<a href="mysite.com/page1">page1</a>
</div>

<div id="section2">
<? $var='value2'; ?>
<a href="mysite.com/page2">page2</a>
</div>

<div id="section3">
<? $var='value3'; ?>
<a href="mysite.com/page1">page3</a>
</div>

Using jquery, javascript, ajax and not php (get, session variable) can i do this? If i click on the link to page1 send $var='value1' to page1 If i click on the link to page2 send $var='value2' to page2 If i click on the link to page3 send $var='value3' to page3

Thank you!

Community
  • 1
  • 1
webmasters
  • 5,663
  • 14
  • 51
  • 78
  • 3
    possible duplicate of [Ajax, javascript send variable to another page, on click](http://stackoverflow.com/questions/4569982/ajax-javascript-send-variable-to-another-page-on-click) Seems to be the same as your previous question. Please clarify, update and comment on your original question instead of creating a new one. – Felix Kling Dec 31 '10 at 13:20

2 Answers2

0

I'm not sure exactly what you're asking, but it sounds like you just want to supply the values on the query string to the destination pages:

<div id="section1">
<? $var='value1'; ?>
<a href="mysite.com/page1?var=<? echo $var; ?>">page1</a>
</div>

<div id="section2">
<? $var='value2'; ?>
<a href="mysite.com/page2?var=<? echo $var; ?>">page2</a>
</div>

<div id="section3">
<? $var='value3'; ?>
<a href="mysite.com/page1?var=<? echo $var; ?>">page3</a>
</div>

Then in each of those pages you'd use $_GET['var'] to access the variable in the PHP code, or access the query string from JavaScript directly.

Community
  • 1
  • 1
David
  • 208,112
  • 36
  • 198
  • 279
0

You could use a cookie. Get/set cookie functions at: http://www.w3schools.com/JS/js_cookies.asp

Eamorr
  • 9,872
  • 34
  • 125
  • 209