SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member jon21021985's Avatar
    Join Date
    Aug 2005
    Location
    UK
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide show div problem

    Hi all, I am using this script to hide and show divs on my webpage, but I can only get it to work with 3 divs, Im not really sure what to change to get it to work for 14 divs, I have had a go already but the 4 div onwards dont turn off when other links are clicked.

    this is what I have so far: http://www.design-direction.net/portfolio/index.html
    the 4th and 5th thumbs are the problem



    I have this in my head section:

    <script type="text/javascript">
    function clearcontent() {
    if (document.getElementById)
    {
    var style2 = document.getElementById("w1").style;
    style2.display = "block";
    var style3 = document.getElementById("w2").style;
    style3.display = "none";
    var style3 = document.getElementById("w3").style;
    style3.display = "none";
    var style3 = document.getElementById("w4").style;
    style3.display = "none";
    var style3 = document.getElementById("w5").style;
    style3.display = "none";
    var style3 = document.getElementById("w6").style;
    style3.display = "none";
    var style3 = document.getElementById("w7").style;
    style3.display = "none";
    var style3 = document.getElementById("w8").style;
    style3.display = "none";
    var style3 = document.getElementById("w9").style;
    style3.display = "none";
    var style3 = document.getElementById("w10").style;
    style3.display = "none";
    var style3 = document.getElementById("w11").style;
    style3.display = "none";
    var style3 = document.getElementById("w12").style;
    style3.display = "none";
    var style3 = document.getElementById("w13").style;
    style3.display = "none";
    var style3 = document.getElementById("w14").style;
    style3.display = "none";
    }
    }
    window.onload=clearcontent;

    function toggleLayer(whichLayer,turnoff1,turnoff2)
    {
    if (document.getElementById)
    {
    // this is the way the standards work
    var turnon = document.getElementById(whichLayer).style;
    var turnoff1 = document.getElementById(turnoff1).style;
    var turnoff2 = document.getElementById(turnoff2).style;
    turnon.display = "block";
    turnoff1.display = "none";
    turnoff2.display = "none";
    }
    }
    </script>




    and I have this on each flash button that control if a div is vissable:

    thumb1 -


    on (release) {
    getURL("javascript:toggleLayer('w1','w2','w3','w4','w5','w6','w7','w8','w9','w10','w11','w12','w13','w14');");
    }


    thumb2 -

    on (release) {
    getURL("javascript:toggleLayer('w2','w1','w3','w4','w5','w6','w7','w8','w9','w10','w11','w12','w13','w14');");
    }


    thumb3 -

    on (release) {

    getURL("javascript:toggleLayer('w3','w2','w1','w4','w5','w6','w7','w8','w9','w10','w11','w12','w13','w14');");
    }




    and so on



    please can anyone help my figure out how to get this to work on more than 3 divs...thanks...jon
    New Portfolio coming soon....

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see any trouble with the 4th and 5th thumb ?

    Also im not being experienced in flash, but using javascript:function as URL is really bad pratice, sure there is not a onClick solution ? (or inline JS in flash).

    I would though recomend a reconstruction of your code, using a range, or a array instead of such long urls.

  3. #3
    SitePoint Member jon21021985's Avatar
    Join Date
    Aug 2005
    Location
    UK
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you click on thumb 4 and then thumb 3, you will se what I mean, also what do you mean by a range? array? I dont know anything about javascript cany anyone help with this?...thanks...j
    New Portfolio coming soon....


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
  •