Javascript - Remember what was selected after refresh
Hi all,
I have a simple drop down that allows you to choose a country. On my site if the address in the form comes out wrong it refreshes the page and brings up a validation box. If someone choses Canada it defaults back to the US when the page refreshes. With javascript could it remember Canada after the refresh?
You could append the URL with parameters (document.html?country=CAN) and keep appending the URL with them if they exist.
Easier, though, would be cookies. Set a value in document.cookie for country, and have JavaScript check for the existence of the cookie on every page load - if it exists, grab the value and set the select for that value.
Even easier, though, would be a server-side solution (ColdFusion, ASP, PHP, JSP, etc.) You'd be able to set the SELECTED parameter of that option as the form is being built.
Bookmarks