I try to implement a multilanguage system to my website, but don’t know how to keep the value of a variable ( lang ) during website surfing. If I could do that, the rest is easy. Do you have any ideas? I don’t want to use sessions. Thankx!
@A1ien51Aug 13.2005 — #JavaScript is stateless, you can not keep a value in memory so you need to use a cookie or append the data you want to pass from page to page as a query string.
Just a thought if your pages have forms that are being passed back and forth to your server why not use a hidden field to store the data rather than a JS variable. This will naturally be posted each time the form is processed.
Your JS code could then change the value of this dependant on whatever method you have for the user to choose their language. After the initial POST of the data,each time you build your HTML that is returned simply recreate this field with POST data for field "lang' from the previous submission.
To access it in JS thereafter simply use the usual methods for accessing form elements.