Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: hide element

  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    hide element

    Hello,
    The code below shows a layer when the "click me" link is clicked. How can I use the "hidelyr" function to hide the layer with the same "click me " link so the user can remove the layer they just opened??

    <SCRIPT language="JavaScript">
    <!--
    function LoadPage(lyr_ID,oLeft,oTop) {
    document.getElementById(lyr_ID).style.visibility = "visible";
    document.getElementById(lyr_ID).style.pixelLeft=oLeft
    document.getElementById(lyr_ID).style.pixelTop=oTop

    }

    function hidelyr(lyr_ID) {
    document.getElementById(lyr_ID).style.visibility = "hidden";
    }


    // -->
    </SCRIPT>
    <a href="javascript:LoadPage('layer_1',100,200)"; >Click Me</a>

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function LoadPage(lyr_ID,oLeft,oTop) {
    document.getElementById(lyr_ID).style.visibility = (document.getElementById(lyr_ID).style.visibility == "visible") ? "hidden" : "visible";
    document.getElementById(lyr_ID).style.pixelLeft=oLeft
    document.getElementById(lyr_ID).style.pixelTop=oTop
    
    }
    .....Willy

  • #3
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts
    Works perfect. Thanks Willy

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your welcome but as an aside...
    I would advise using style display as oppose to style visibility so that the element does not take up any space on the page when hidden...

    .....Willy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •