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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide All Function

Status
Not open for further replies.

indigoblue

Programmer
Sep 7, 2000
9
0
0
GB
i have a function hideMenu:

function hideMenu(menu){

if (document.layers){

hMenu = document.layers[menu];
}
else if (document.all){

hMenu = document.all(menu).style;
}

hMenu.visibility = hidden;
}

That hides divs. I want to make sure that all the divisions are well hidden when the page loads. The divisions are numbered 0-9, so I thought I could have a function called hideAll which went something like this:

function hideAll(){

for(i = 0;i < 10; i++){

if (document.all){
var toHide = document.all(i);
}

else if (document.layers){
var toHide = document.layers;
}
hideMenu(toHide);
}
but it doesn't work (I'm calling it through <body onLoad=&quot;hideAll();&quot;>

Could someone please put me out of my misery? [sig][/sig]
 
try this:

function hideAll() {
var toHide;
for (i = 0; i < 10; i++) {
if (document.all) {
toHide = document.all.style
} else {
toHide = document.layers
}
toHide.visibility = hidden;
}
}


or you might have to reference i inside the array like this: [&quot;'&quot; + i + &quot;'&quot;] [sig]<p>ray<br><a href=mailto:rheindl@bju.edu>rheindl@bju.edu</a><br><a href= > </a><br> [/sig]
 
But the lopp variable i isn't referenced anywhere in the loop... [sig][/sig]
 
sorry, but my post got really messed up because is thinks that (i) , but with brackets, is a markup tag for italics; it should read :

toHide = document.all(i).style
and:
toHide = document.layers(i)

just substitute brackets for the parentheses [sig]<p>ray<br><a href=mailto:rheindl@bju.edu>rheindl@bju.edu</a><br><a href= > </a><br> [/sig]
 
You can stop your code from being processed by the Tek-Tips TGML processor by either unchecking the &quot;Process TGML&quot; check box, or enclosing it within IGNORE /IGNORE TGML tags. [sig]<p>nick bulka<br><a href=mailto: > </a><br><a href= </a><br>Get your technical books at Bulka's Books<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top