Log in

View Full Version : Javascript stylesheet swap based on cookie



kristiandavid
10-21-2009, 04:25 PM
ok here's my issue.

i have a login page which remembers the inputted password in a cookie. once the login is successful, i need to dynamically load one of 2 stylesheets based on the password value in the cookie.

this is for a demo so i only need it to change between 2 stylesheets and i'm only using 2 possible passwords. seems like it's not that hard but my brain is fried. please help!!!

Kristiandavid

bluewalrus
10-21-2009, 05:31 PM
Got a link and or code?

kristiandavid
10-21-2009, 05:41 PM
this makes the cookie :
function set_cookiePass(c_pass, form){
document.cookie=c_pass+"="+form.Password.value;
}


this is the sumbit button;
<input name="Submit" type="submit" value="Submit" onclick="set_cookiePass('password',this.form);MM_goToURL('parent','http://66.11.64.70/csp2/main2.html');return document.MM_returnValue" />

those work fine, now i just need to grab the cookie on the following page and based on the password value, change the stylesheet.

ie : if user enters 'pass1' as the password, the following page will load 'style1.css'
if user enters 'pass2' as the password, the following page will load 'style2.css'