Chocolate570 Posted January 18, 2006 Share Posted January 18, 2006 I'm making a new site. Now, on this site will be a style switcher. I'm going to have 4 styles, and i want the site to remember the member's style choice. I'd like to do this in javascript....php is a no-no for me, for various reasons. So, my select box will be like this:<select onchange="switchStyle(this)"><option value=blue>Blue<optionvalue=red>Red<option value=silver>Silver<optionvalue=green>Green</select>Now I need a javascript function which sets a cookie to the select option.Then I need another one that checks the cookie, and according to the cookie, puts down a different stylesheet.I know this is a big request, and I thank anyone who does it for me. Link to comment Share on other sites More sharing options...
Skemcin Posted January 18, 2006 Share Posted January 18, 2006 Here is a tutorial that should help:http://www.quirksmode.org/js/cookies.html(skip the intro stuff and go right to the examples and script source half way down)Setting the cookie will be easy enough, the creative part is using the cookie to determine what stylesheet to use.Do to this, you;ll have to use the document.write statement to render the correct absolute link to the stylesheet the cookie remembers.Set the valueof the cookie to the filename (dropping the .css) of the stylesheet theme and then render that cookie value in the respective javascript condition. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now