#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    3
    Rep Power
    0
    when I use this javascript:

    function inView(num){
    if (num==1){
    show('existing');
    hide('new');
    }
    else
    show('new');
    hide('existing');
    }

    function show(object) {
    if (document.layers && document.layers[object] != null)
    document.layers[object].visibility='visible';
    else if (document.all)
    document.all[object].style.visibility='visible';
    }

    function hide(object) {
    if (document.layers && document.layers[object] != null)
    document.layers[object].visibility='hidden';
    else if (document.all)
    document.all[object].style.visibility='hidden';
    }

    The 'new' layer is shown and the existing is hidden. BUT when I try to show the 'existing' layer, it doesn't show, but the 'new layer goes away.

    this is some html that calls it:

    <center>
    <input type=button value="Use NEW Library" onClick="inView(2);">
    <input type=button value="Use EXISTING Library" onClick="inView(1);">


    this is how I made the layers:
    <DIV id="existing" style="position:absolute; left:10px; top:300px; width:100%; height:1000; visibility:visible">

    <DIV id="new" style="position:absolute; left:10px; top:300px; width:100%; height:200px; visibility: hidden">

    Please HELP!!!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Posts
    84
    Rep Power
    16
    Here is a script I put together. It's essentially like yours but this works:

    <html>
    <head>
    <title>Hide/Show Multiple Layer Script</title>
    <script language="JavaScript">
    <!--//
    function show(layerid) {
    if (document.all){
    layerid.style.visibility="visible"
    }
    else
    if(document.layers){
    layerid.visibility="show"
    }
    }
    function hide(layerid){
    if (document.all){
    layerid.style.visibility="hidden"
    }
    else
    if(document.layers){
    layerid.visibility="hide"
    }
    }
    //-->
    </script>
    </head>
    <body>
    <a href="javascript:void(null);" onClick="show(myText01);">Show Text 01</a><br>
    <a href="javascript:void(null);" onClick="hide(myText01);">Hide Text 01</a><br>
    <br>
    <a href="javascript:void(null);" onClick="show(myText02);">Show Text 02</a><br>
    <a href="javascript:void(null);" onClick="hide(myText02);">Hide Text 02</a><br>

    <div id="myText01" style="position:relative;visibility:visible">
    <h1>Here is some text</h1>
    </div>

    <div id="myText02" style="position:relative;visibility:visible">
    <h1>Here is some more text</h1>
    </div>

    </body>
    </html>

    Spookster

Similar Threads

  1. SWAP method for DIV layers?
    By * Val * in forum HTML Programming
    Replies: 5
    Last Post: February 29th, 2004, 07:15 PM
  2. Overlapping Div layers
    By UrbanDeveloper in forum HTML Programming
    Replies: 7
    Last Post: September 1st, 2003, 10:07 PM
  3. hiding and showing div layers
    By bramsey in forum HTML Programming
    Replies: 2
    Last Post: January 10th, 2002, 09:09 AM
  4. left - right scroll in div layers
    By Ulrik N in forum HTML Programming
    Replies: 4
    Last Post: May 21st, 2001, 10:38 PM
  5. Replies: 1
    Last Post: February 3rd, 2001, 01:20 PM

IMN logo majestic logo threadwatch logo seochat tools logo