PDA

View Full Version : hide element



nikko50
10-31-2004, 01:25 PM
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>

Willy Duitt
10-31-2004, 02:35 PM
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

nikko50
10-31-2004, 03:26 PM
Works perfect. Thanks Willy:)

Willy Duitt
10-31-2004, 03:53 PM
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