Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding/Showing DIVs?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
It seems like a fairly easy thing to do, but I seriously can not get my script to work. It consists of two functions:

function itemshow(itemshow) {
itemshow.visibility = "visible"
}
fuction itemhide(itemshow) {
itemshow.visibility = "hidden"
}

And my DIV to show and hide:

<div id=&quot;main&quot;><img SRC=&quot;images/bigitem1.gif&quot;></div>

And finally my links to hide and show it:

<a href=&quot;#&quot; onclick=&quot;itemshow(main)&quot;>Show It, Baby!</a>
<a href=&quot;#&quot; onclick=&quot;itemhide(main)&quot;>Hide It, Baby!</a>

I'm probably doing something incredibly stupid, but hey, I'm a newbie at this... thanks in advance for any help you can give =D

-Maalox
 
itemshow.style.visiblity should do it jared@aauser.com
 
oops forgot to mention that my solution above only works in IE4+ and NS6. In older versions of NS you probably have to use something like:

document.layers.main.visibility='hide'

or

document.layers.main.visibility='show'
jared@aauser.com
 
Try something like this:

if (document.layers)
{
var doc = &quot;document.layers.&quot;;
var style = &quot;.&quot;;
var hide = &quot;'hide'&quot;;
var show = &quot;'show'&quot;;
}

if (document.all)
{
var doc = &quot;document.all.&quot;;
var style = &quot;.style.&quot;;
var hide = &quot;'hidden'&quot;;
var show = &quot;'visible'&quot;;
}

function itemshow(itemshow)
{
eval(doc+itemshow+style+&quot;visibility=&quot;+show);
}
fuction itemhide(itemshow)
{
eval(doc+itemshow+style+&quot;visibility=&quot;+hide);
}

You may want to add another condition for neither document.layers nor document.all and disable the function for those browsers.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top