What's the best way to pass a variable from one page to another in javascript?
p
![]()
| SitePoint Sponsor |


What's the best way to pass a variable from one page to another in javascript?
p
![]()
Philip Toews Professional esl Educator and ASP.NET wannabe
http://www.philiptoews.com
philip@philiptoews.com



The only method that I'm aware of achieving something like this is to store the value of the variable in a cookie. Should this be running server-side however, you could add it to a hidden input field, and retrieve it from the submitted data. Alternatively, pass it through as a QueryString or in ASP, set a Session or Server-Side cookie variable containing the value, should it be used throughout the site.
There might be a number of other, easier methods, but in that case I think I can also learn something new from this thread.
- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.


For the particular application I have to develop a server side solution is not workable
p![]()
Philip Toews Professional esl Educator and ASP.NET wannabe
http://www.philiptoews.com
philip@philiptoews.com


You can also send the value by attaching it to the url of the next page. Here is a link to a tutorial on the subject:
http://www.wsabstract.com/javatutors/send1.shtml



I think your best bet in this case is to store the value in a cookie, or as mentioned by requestcode, within the URL
- Pip
---------------------------------------------------------------------------------
Nothing takes the taste out of peanut butter quite like unrequited love.
Bookmarks