Results 1 to 7 of 7

Thread: Switch Content showstate problems

  1. #1
    Join Date
    Aug 2005
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Switch Content showstate problems

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

    I am having problems with the expand/contract "showstate" function. I have four sections that expand, the first works just fine, the 2nd when expanded changes the "showstatus" for the 3rd but not itself, the 3rd when expanded changes nothing, same with the 4th. When I use the expand all function (accessed with the top 'print page' image), all four change properly.

    I tried using both the default html + / -, as well as my own graphics.

    Everything else works perfectly and the script is fantastic for my needs.

    My test page:
    url: http://www.cyclevents.com/test/test3.htm

  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

    My guess is that the <b></b> element is ignored and that the script is keying off of the <p></p> element. Try substituting:

    <span style="font-weight:bold"

    for:

    <b

    and:

    </span>

    for:

    </b>
    - John
    ________________________

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

  3. #3
    Join Date
    Aug 2005
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the idea but no go. I even tried eliminating the <p>,</P>, but still the same results.

    But I did discover that it has something to do with the smaller div containing graphics. My page is laid out, using blocks of text and graphic image separators:

    text
    graphic
    text
    graphic
    . . . . . etc

    The links open each of the text sections individually, and when you use the sweeptoggle('expand') it opens everything, so that the images break up the bigger page visually.

    If I delete the graphic div's then it works just fine. Or if I add "links" to each of the graphic div's it works fine, but I end up with extra x/-'s that only show horizontal bars.

    Ultimately I could build the horizontal bar into each text section, but it is much cleaner if I can figure out how to do it through the Switch Content functions.

    Any ideas ??

  4. #4
    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

    It's definitely those extra divisions:

    <div id="tour5" class="switchcontent">

    I'd give them a different class name and no id. Then I'd control their behavior separately, let's change the class name to "printdivider":

    <div class="printdivider">

    Now in the style, set that class to display:none -
    Code:
    <style type="text/css">
    .printdivider {
    display:none;
    }
    </style>
    Then, wherever/whenever you want them to appear/disappear in the script or elsewhere, they can be addressed thusly:

    To disappear:
    Code:
    printDivs=document.getElementsByTagName('div')
    for (var i = 0; i < isrc.length; i++)
    if (printDivs[i].className=='printdivider')
    printDivs[i].style.display='none'
    To appear:
    Code:
    printDivs=document.getElementsByTagName('div')
    for (var i = 0; i < isrc.length; i++)
    if (printDivs[i].className=='printdivider')
    printDivs[i].style.display='block'
    Notes:
    Just a rough idea, it will work. Better to start out with the dividers displayed and hide them onload using javascript, so that they are there for non javascript browsers. The hide/display code can be more efficient and if done right, the printDivs variable only needs to be declared once.
    Last edited by jscheuer1; 08-24-2005 at 02:10 PM.
    - John
    ________________________

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

  5. #5
    Join Date
    Aug 2005
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks again John, but being "javascripting challenged" to the max (when I learned programming in college, fortran was the newest thing ) I am having a hard time figuring out exactly where you mean for me to incorporate those snippets of code. I tried a bunch of experiments (ie: guesses) without success.

    You did get me thinking and after perusing a ton of javascript tutorials, I did come up with an alternative solution by adding the following to the script:

    function printbar(thistag) {
    styleObj=document.getElementById(thistag).style
    styleObj.display="block"
    }
    function noprintbar(thistag) {
    styleObj=document.getElementById(thistag).style;
    styleObj.display="none";
    }

    function pageprint(){
    sweeptoggle('expand')
    printbar('pd1')
    printbar('pd2')
    printbar('pd3')
    print()
    }



    And then modifying the contractcontent function, to eliminate the bars:

    function contractcontent(omit){
    var inc=0
    while (ccollect[inc]){
    if (ccollect[inc].id!=omit)
    ccollect[inc].style.display="none"
    inc++
    }
    noprintbar('pd1')
    noprintbar('pd2')
    noprintbar('pd3')

    }

    I am sure there maybe an easier way to do this, so that I don't have to specify each of the div's individually. . . . . . .

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

    Default

    Code:
    for(i=1;i<=3;i++) printbar('pd'+i);
    for(i=1;i<=3;i++) noprintbar('pd'+i);
    Last edited by Twey; 08-24-2005 at 06:40 PM.
    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!

  7. #7
    Join Date
    Aug 2005
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thank you Twey, that did the trick

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
  •