PDA

View Full Version : Style Sheet Switcher - 1 link for both



Pea
11-14-2006, 05:21 PM
Hi

I'm using the Style Sheet Switcher and would like to have just 1 button that can switch between the 2 CSS files I have.

Currently i'm using:

<a href="javascript:chooseStyle('orange', 60)">Orange</a>
<a href="javascript:chooseStyle('grey', 60)">Grey</a>

..but would like one link that switches between them. Is this possible?

Thanks

ddadmin
11-15-2006, 09:28 AM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

This is untested yet but should work. Try this code:


<script type="text/javascript">

function chooseStyleAlt(days){
if (document.getElementById){
var selectedtitle=getCookie("mysheet")
if (selectedtitle=="orange")
chooseStyle('grey', days)
else
chooseStyle('orange', days)
}
}

</script>

<a href="javascript:chooseStyleAlt(60)">Switch between Gray and Orange style</a>

djr33
11-15-2006, 09:32 AM
Just for the record, it would be possible to switch the name of the link each time it was clicked, but that would be a lot harder. Using the above code should do fine.... just make the link called something generic.