Results 1 to 3 of 3

Thread: Switch Content Script - Multiple DIVs Open By Default

  1. #1
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Switch Content Script - Multiple DIVs Open By Default

    Script: Switch Content Script
    http://www.dynamicdrive.com/dynamici...tchcontent.htm

    First, let me thank the authors of the site for a collection of great scripts. I particularly like this one for its fantastic backwards compatibility.

    I would like to setup the script to automatically have several divs open by default. For example, on a page with twelve div "sections" I would like to have sections one, three, eight, and nine "open" by default with the others "closed" but set to open upon click. It's fine to either specify these within the div or within the javascript, as I want it displayed the same way on each page.

    I've dug through the forums and found a variety of relevant postings. Unless I've overlooked something, this doesn't seem to work with the current "Switch Content Script" from the URL at the top.

    Those instructions do work using the script in the third message in this post, but it isn't quite as advanced as the "Switch Content Script", so I'd rather use it if at all possible.

    Following the instructions in this post, I had no problem modifying the stock Switch Content Script to have one DIV open by default by finding "revivestatus()" at the end of the "function do_onload(){" and changing it to this:

    Code:
    revivestatus()
    sweeptoggle('contract')
    expandcontent(statecollect[0].parentNode, 'sc1');
    That will make the first section open by default, but I'm not sure how to change it to make other sections open as well. What am I overlooking?

    Thank you very much for your help.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You can add as many of those type statements as you need, for example, to have the first two open use:

    Code:
    revivestatus()
    sweeptoggle('contract')
    expandcontent(statecollect[0].parentNode, 'sc1');
    expandcontent(statecollect[1].parentNode, 'sc2');
    Notice the format, statecollect[#] is one less that sc#.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    D'oh! I swear I already tried that, as it was the intuitive thing to do, but I must have forgotten to change statecollect. That works perfectly. Thank you.

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
  •