Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    24
    Member #
    16485
    Hi all

    A show/hide divs problem.

    Some text is clicked to reveal two images.

    Why when you click to hide just one div and then click "show/hide divs" does it swap to reveal the div just hidden.

    I want to be able to click one "hide div" link to hide each individual div and also to click "show/hide divs" to hide the rest (not swap and show the hidden one)

    see what i mean below
    ------------------------------------------------------------------------------------------------

    <html>
    <head>


    <!-- SHOW-HIDE MULTIPLE SCRIPT -->
    <script language="javascript">
    function expandCollapse() {
    for (var i=0; i<expandCollapse.arguments.length; i++) {
    var element = document.getElementById(expandCollapse.arguments[i]);
    element.style.display = (element.style.display == "none") ? "block" : "none";
    }
    }
    </script>

    <!-- SHOW-HIDE SINGULAR SCRIPT -->
    <script language="javascript">
    function showHide(element) {
    if (document.getElementById) {
    // W3C standard
    var style2 = document.getElementById(element).style;
    style2.display = style2.display ? "" : "block";
    }
    else if (document.all) {
    // old MSIE versions
    var style2 = document.all[element].style;
    style2.display = style2.display ? "" : "block";
    }
    else if (document.layers) {
    // Netscape 4
    var style2 = document.layers[element].style;
    style2.display = style2.display ? "" : "block";
    }
    }
    </script>

    </head>

    <body>

    <!-- INITIAL EXPAND/COLLAPSE ALL DIVS -->
    <div>
    <a href="javascript: expandCollapse('image1','image2');">Show/Hide Divs</a>
    </div>

    <br>
    <br>

    <!-- INDIVIDUAL DIVS -->
    <div id="image1" style="display:none;" class="image1">
    <a href="#" onClick="document.getElementById('image1').style.d isplay='none';">Hide Div</a>
    <br>
    <img src="/image1.jpg">
    </div>

    <br>
    <br>

    <div id="image2" style="display:none;" class="image2">
    <a href="#" onClick="document.getElementById('image2').style.d isplay='none';">Hide Div</a>
    <br>
    <img src="/image2.jpg">
    </div>

    </body>
    </html>



    ------------------------------------------------------------------------------------------------



    any ideas?

    ben

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:08 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com