Forum Moderators: open

Message Too Old, No Replies

Showing elements

Having issues using visibility

         

Numberman

10:42 pm on Jun 25, 2004 (gmt 0)

10+ Year Member



I'm having trouble displaying a div element.

Exerp from my func.js:


// Functions

function hide(id)
{
element = document.GetElementById(id);
element_id.style.visibility = "hidden";
}

function show(id)
{
element = document.getElementById(id);
element_id.style.visibility = "show";
}

The DIV:


<div id="divgallerymenu" style="position:absolute; left:161px; top:276px; width:159px; height:190px; z-index:1; background-color: #FF0000; layer-background-color: #FF0000; border: 1px none #000000; visibility:hidden">
<p>Flash Gallery</p>
<p>Animated GIF</p>
<p>Picture</p>
</div>

The link:


<a href="javascript://" onClick="show('divgallerymenu')">Galleries</a>

I'd appreciate some help. The DIV refuses to show.

DrDoc

11:42 pm on Jun 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



element_id.style.visibility = "show";

That should be:

element_id.style.visibility = "visible";

Numberman

12:50 am on Jun 26, 2004 (gmt 0)

10+ Year Member



I feel very stupid for making that mistake, but the corrected version still doesn't work. I've tried it in both FireFox and Internet Explorer.

Bernard Marx

1:28 am on Jun 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



element = document.GetElementById(id);
element_id.style.visibility = "hidden";

:)

PS write:

var element = document.getElementById(id);

to make it a local variable. Not an 'error', but better.

AND

This:

<a href="javascript://" onClick="show('divgallerymenu')">Galleries</a>

might be better as:

<a href="#" onClick="show('divgallerymenu');return false">Galleries</a>

Rambo Tribble

1:34 am on Jun 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just so you aren't confused, show is the old Netscape 4 layers terminology. Also note that after you declare your element as var element, you must use it as element, not element_id.

Numberman

8:57 pm on Jun 26, 2004 (gmt 0)

10+ Year Member



Your help was greatly appreciated.