...

View Full Version : CSS style switcher



Mardiuzzz
01-18-2006, 09:35 AM
Hi all,

Since i've had such good experiences with this forum I'll try my luck with yet another problem.

I am building a site with a css styleswitcher. It's working with a 'normal' textlink to switch css styles.

I want to make it work within a dropdown list. I got it to work in Firefox (Mac) but not any other browsers for Mac (haven't tried PC yet though). So my question; does firefox use different coding for something like this?

this is the url of the site: http://www.m-go.nl/www2/index2.html

the dropdown menu is:

<form name="form2" id="form2">
<select name="menu1">
<option onclick="setActiveStyleSheet('style');return false;">Blue</option>

<option onclick="setActiveStyleSheet('style2');return false;">Urban decay</option>
</select>
</form>

and the 'normal' textlink is:

<a onclick="setActiveStyleSheet('style2');return false;" href="#">Change style to urban decay</a>
<a onclick="setActiveStyleSheet('style');return false;" href="#">Change style to blue</a>

any thoughts?
bye

glenngv
01-18-2006, 09:46 AM
It works in FF on PC. But not in IE because onclick event is not supported in option tag in IE. Use onchange in the select tag for wide cross-browser support.

<select name="menu1" onchange="setActiveStyleSheet(this.options[this.selectedIndex].value)">
<option value="style">Blue</option>
<option value="style2">Urban decay</option>
</select>

Mardiuzzz
01-18-2006, 10:01 AM
tanx! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum