Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Switch Content Script

  1. #1
    Join Date
    Sep 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switch Content Script

    Script: switch content script
    http://www.dynamicdrive.com/dynamici...tchcontent.htm

    This is a great cross-browser script. I am looking to enhance it by including a "display/hide all" link at the top of the outline. Could you help me out with how I could go about getting this to work.

    Thanks
    Kari
    Last edited by Snookerman; 06-18-2009 at 11:53 AM.

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

    Default

    Edit: This code updated April 2nd, 05' to work with latest version of the script (namely, the state symbols "+" and "-").

    Sure. Firstly, add the below function to the code of Step 1:

    Code:
    function sweeptoggle(ec){
    var thestate=(ec=="expand")? "block" : "none"
    var inc=0
    while (ccollect[inc]){
    ccollect[inc].style.display=thestate
    inc++
    }
    revivestatus()
    }
    With that done, add the below two links somewhere within your visible HTML, which will contract/ expand the entire switch content when clicked on, respectively:

    Code:
    <!--Optional Expand/ Contact All links. Remove if desired-->
    <div><a href="javascript:sweeptoggle('contract')">Contract All</a> | <a href="javascript:sweeptoggle('expand')">Expand All</a></div>
    Last edited by ddadmin; 04-02-2005 at 07:42 PM.

  3. #3
    Join Date
    Sep 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wink Thanks

    That's awesome, exactly what I was looking for. Thank you for your quick response.
    Kari

  4. #4
    Join Date
    Feb 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switch Content Expand All (+)(-)

    Hi,

    This question has been answered to create a "Contract All" and "Expand All" feature.

    http://www.dynamicdrive.com/forums/s...switch+content

    I think this was done before the (+)(-) was an added feature. It works great, but the plus (+) sign doesn't change to a minus (-) sign when I click "Expand All". The content is expanded, it's just the symbols don't change.

    Here's the updated version:

    http://www.dynamicdrive.com/dynamici...tchcontent.htm

    I tried playing with the code, but I couldn't get it.
    Any help would be much appreciated.


    Thank you

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

    Default

    It seems more than a few people have requested a "Expand all" feature, so I'll look at officially updating the script for it. I'll post a heads up if the script is modified for this.

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

    Default

    Ok, I've updated the code above to account for the latest version of Switch Content script. The same update can also be found in the official version of the script: http://www.dynamicdrive.com/dynamici...tchcontent.htm

    The contact/expand links tie in with the persistence feature, so they're remembered as well.

  7. #7
    Join Date
    Feb 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thank you. This forum is awesome!

  8. #8
    Join Date
    Jul 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Swtich Content Script

    http://www.dynamicdrive.com/dynamici...tchcontent.htm

    Hi all. I'm not sure if anyone is still viewing this thread but I was wondering if I could get hand with something.

    I use the code at the above url to have content appear on demand. I use it not only for links but for anything I'd like to hide for the mement without having to create a pop up or another page. However, my issue is that I'd like the first expandable content to be viewed right away but once someone clicks on a specified link the first one dissapears and the second appears in its place.

    I'm not the most experienced at code but I was trying simply having an onLoad command in the <body> tag something like:

    <body onLoad="expandcontent(this, 'sc1')">

    But I didn't have any luck. I've tried putting the assignment in different tags but still no luck. Like I said, I'm far from being experienced. I was hoping that maybe someone might provide some help. It would be greatly appreciated.

  9. #9
    Join Date
    Jul 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by spyr
    http://www.dynamicdrive.com/dynamici...tchcontent.htm

    Hi all. I'm not sure if anyone is still viewing this thread but I was wondering if I could get hand with something.

    I use the code at the above url to have content appear on demand. I use it not only for links but for anything I'd like to hide for the mement without having to create a pop up or another page. However, my issue is that I'd like the first expandable content to be viewed right away but once someone clicks on a specified link the first one dissapears and the second appears in its place.

    I'm not the most experienced at code but I was trying simply having an onLoad command in the <body> tag something like:

    <body onLoad="expandcontent(this, 'sc1')">

    But I didn't have any luck. I've tried putting the assignment in different tags but still no luck. Like I said, I'm far from being experienced. I was hoping that maybe someone might provide some help. It would be greatly appreciated.

    Never mind! Sorry to waste everyone's time but stupid me just found the answer.

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Which was...?
    The "this," shouldn't be there?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •