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 / Show Layers

Status
Not open for further replies.

Nebooaw

Programmer
Jun 1, 2001
142
0
0
GB
Hi, if i have a page with multiple layers on it (some having the same name) how can i show / hide all layers with the same name.

eg.

Layer1
Layer2
Layer2
Layer2
Layer3
etc..

I want a button to hide all Layer2 layers.


Can anyone help?

Al.

 
Have you tried using a subscript after the layer name?

Meddle not in the affairs of dragons,
for you are crunchy, and good with mustard.
 
<script>
AllLayers=document.getElementsByTagName("div")
for(i=0;i<AllLayers.length;i++)
{
if(AllLayers.id=="Layer2)
{
AllLayers.style.display="none"
}
}
</script>

NOTE:
i have used Id of the layer, if its name that u want please use:
AllLayers.name

...

Known is handfull, Unknown is worldfull
 
You could also try this:
Code:
[i]collObjects[/i] = document.[b]getElementsByName[/b]([i]sNameValue[/i])
Although it says "by name", according to the MSDN web site it will look for name OR id. If there are multiple with the same name, you will get a collection (i.e. an array) of those elements.


Meddle not in the affairs of dragons,
for you are crunchy, and good with mustard.
 
Thanks vbkris, think this is what im after.


Kindest regards,

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top