DOM1/ Netscape6 question

by anottingham(at)topazti.com (Amy Nottingham)

 Date:  Wed, 7 Mar 2001 15:17:11 -0600
 To:  "HWG techniques" <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
Hello Everyone,

I am trying to get my site up to speed so it works in Netscape 6, etc.  I
have pop-up menus that are each inside a set of layer tags and div tags, and
code like the following that makes them visible or not:

For netscape 4.x (document.layers)

	document.layers[i+1].visibility = "hide"
      document.layers[x+1].visibility = "show"

For IE 4.x/5 (document.all)

	document.all.box[i].style.visibility = "hidden"
      document.all.box[x].style.visibility = "visible"

where i is a variable incremented in a loop (that makes all the menus
invisible) and x is a value that gets passed to the function depending on
which menu gets moused-over, which makes it visible.  The nice thing about
this code is that the divs don't have a unique id, they are all called "box"
and then referred to as part of an array, so I don't have to mess with a
series of if/else or case/switch statements.

Now for my problem:

I cannot figure out how to pass and element of an array to the getElementId
method of document (which as far as I have been able to figure out, is what
I should use for Netscape 6 and other browsers that support DOM1).

I have tried:

document.getElementByID('box[x]').style.visibility="visible"
document.getElementByID('box').x.style.visibility="visible"
and even building something like var menu="'box[" + x + "]'" and then
document.getElementById(menu).style.visibility="visible"

but none of these have worked.  (I know some of these may seem silly to you
JavaScript pros out there, but I tried whatever I could think of).  No
reference I have found deals with this specific situation.  Is there any way
to do this, or am I going to have to resort (EEEEEEEEKKK!) to giving each
div a unique id, and testing to see which menu is visible and which isn't?

I am sorry if this seems really convoluted, it is hard for me to explain
without making it long.

Thanks to everyone in advance for any help!

Amy

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA