...

View Full Version : problems with hiding/showing things



redhead
01-21-2003, 08:20 PM
hi, hopefully someone will be able to help...

ive used this script:

function menu(f){
if(f){visi="visible";}
else{visi="hidden";}
if(document.layers){
document.menu.visibility=visi;
}
if(document.all){
document.all.menu.style.visibility=visi;
}
if(document.getElementById){
document.getElementById("menu").style.visibility=visi;
}
} to hide or show menus for ages and it has never failed me... but i was trying to add something to it so it would be able to show/hide differant layers (eg: menu(1,'moose'); to show a layer cunningly named "moose") but it didnt work. here's how i amended the above script:
function menu(f,which){
if(f){visi="visible";}
else{visi="hidden";}
if(document.layers){
document.which.visibility=visi;
}
if(document.all){
document.all.which.style.visibility=visi;
}
if(document.getElementById){
document.getElementById(which).style.visibility=visi;
}
}

any ideas why this doesnt work? any help would be much appreciated :thumbsup:

joh6nn
01-21-2003, 09:02 PM
well, i don't know if this is all of the problem ( i suspect that it's not ), but :

function menu(f,which){
if(f){visi="visible";}
else{visi="hidden";}
if(document.layers){
document.layers[which].visibility=visi;
}
if(document.all){
document.al[which].style.visibility=visi;
}
if(document.getElementById){
document.getElementById(which).style.visibility=visi;
}
}

landon11
01-21-2003, 09:05 PM
which is a reserved word

joh6nn
01-21-2003, 09:06 PM
that would definitely be another part of the problem. good call

redhead
01-21-2003, 09:12 PM
thanks guys, i had expected it might be that simple. :thumbsup:

thanks again,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum