Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSS style switcher

    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:
    Code:
      <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:
    Code:
    <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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    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.
    Code:
    <select name="menu1" onchange="setActiveStyleSheet(this.options[this.selectedIndex].value)">
       <option value="style">Blue</option>
       <option value="style2">Urban decay</option>
    </select>

  • #3
    New Coder
    Join Date
    Feb 2005
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    tanx!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •