Reputation: 1
So i have a page that effects a javascript var by using a range of dropdown boxes, radio buttons etc. However I need that var to stay the same for that client so when they click add to chart, the var is then followed onto the amount to pay on payment. I'm not sure of the best way to go about it?
Anyone got any pointers to help me?
Cheers
Upvotes: 0
Views: 79
Reputation: 92334
Another solution is to use http://www.thomasfrank.se/sessionvars.html By setting
sessvars.myObj = {name: "Thomas", age: 35}
You will be able to access sessvars
variable from other pages, it's much easier to work than cookies and it has the benefit of not adding cookies to every request to the server. Also cookies can be a pain to encode and decode.
If you only need to support the latest browsers, you should use localStorage.
var foo = localStorage.getItem("bar");
localStorage.setItem("bar", foo);
Upvotes: 1
Reputation: 6809
You could use:
location.search
)location.hash
)If the information must be secure, I would use a POST form and server-side scripting. Otherwise I would use cookies or local storage.
Upvotes: 2