-
style changer help
I have a style changer and I want it so when someone selects the color they want, it stays saved.
HTML Code:
HTML Code:
<script type="text/javascript">
function changeStyle(href){
if(href){
document.getElementById("style-reset").href = "layout/css/reset.css";
document.getElementById("style").href = "style.css";
document.getElementById("style-variation").href = href;
}
else{
alert("No stylesheet entered.");
}
}
</script>
And the dropdown box with the different colors:
HTML Code:
HTML Code:
<li><a href="#" onclick="changeStyle('layout/css/style1.css');">Blue</a></li>
<li><a href="#" onclick="changeStyle('layout/css/style2.css');">Black</a></li>
<li><a href="#" onclick="changeStyle('layout/css/style3.css');">Green</a></li>
<li><a href="#" onclick="changeStyle('layout/css/style4.css');">Purple</a></li>
<li><a href="#" onclick="changeStyle('layout/css/style5.css');">Red</a></li>
<li><a href="#" onclick="changeStyle('layout/css/style6.css');">Olive</a></li>
__________________
-
You need cookies. I'm not that great with writing javascript from scratch but maybe you could look at this jQuery stylesheet switcher with cookie save functionality: http://www.cssnewbie.com/simple-jque...heet-switcher/
The demo page has the copy-and-paste source code in full: http://www.cssnewbie.com/example/stylesheet-switcher/
Just make sure you also download jQuery: http://jquery.com/
And the cookie plugin that the stylesheet switcher uses: http://plugins.jquery.com/project/Cookie
(and remember to change the script paths in the head to point to them)