Results 1 to 5 of 5

Thread: Style Sheet Switcher don't remember selection in drop down list

  1. #1
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Style Sheet Switcher don't remember selection in drop down list

    1) Script Title: Styyle Sheet Switcher

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...etswitcher.htm

    3) Describe problem: I am using a drop down list to select alternative css files. Upon changing to another style, the page is styled nicely. Close the browser then go back to the same url (www.viewspot.net/family). Last selected style is applied, but drop down list item selected does not.

    Site url: www.viewspot.net/family

    Change the style on the drop down list at the top. Close the browser, then go back to it. Style remains, drop selection don't.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    In order for the select box to match the currently persisted style, you need to call the optional indicateSelected() function. This is described on the script page actually:

    "Finally, if you're using radio buttons or a select menu for the switch interface, you can let the script automatically check/select the radio buttion/select option that corresponds to the currently applied alternate style sheet when the page loads. So lets say the user had chosen "Blue theme" a few days ago. Upon his return, the script can check the "Blue theme" choice inside the HTML automatically. To do this, add the below little script to the HEAD section of your page:

    Code:
    <script type="text/javascript">
    window.onload=function(){
    var formref=document.getElementById("switchform")
    indicateSelected(formref.choice)
    }
    </script>
    where "switchform" is the ID of the form of the switch interface, and "choice", either the name of the radio buttons or select menu. If the switch interface appears on all pages of your site, consider moving the above script inside "styleswitch.js"."

  3. #3
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the speed reply. I have included the code you mentioned but it is throwing an error:

    Line 167
    Error: 'type' is null or not an object

    http://www.viewspot.net/family

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Try changing:

    Code:
    indicateSelected(formref.choice)
    to:

    Code:
    indicateSelected(formref.switchcontrol)
    to correctly reflect your SELECT element's name attribute.
    Last edited by ddadmin; 11-30-2007 at 07:54 PM.

  5. #5
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thank you, top man!

    Quote Originally Posted by ddadmin View Post
    Try changing:

    Code:
    indicateSelected(formref.choice)
    to:

    indicateSelected(formref.switchcontrol)

    to correctly reflect your SELECT element's name attribute.
    Thank you very much. Your hep was great and very quick. Top man!

Bookmarks

Posting Permissions

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