Connecting Tech Pros Worldwide Forums | Help | Site Map

document.getElementById(toggle[i]) has no properties

Newbie
 
Join Date: Jan 2008
Posts: 2
#1: Jan 19 '08
I'm getting an error message in FF2.0:

document.getElementById(toggle[i]) has no properties

The goal of the script is, when I hover my mouse over an image, to make one div element visible while making all the others div elements in the array, hidden.

thisDocId is the element to avoid hiding.

This is the script:
[HTML]<script>
function makeHidden(thisDocId) {
var toggle = new Array();
toggle[0] = "about_us";
toggle[1] = "merchants";
toggle[2] = "associations";
toggle[3] = "consumers";
toggle[4] = "newsandevents";

for (i=0;i<toggle.length;i++) {
if (toggle[i] != thisDocId) {
document.getElementById(toggle[i]).visibility="hidden";
}
}
} //end makeHidden function
</script>[/HTML]

This is part of the HTML:
[HTML]<a href="aboutus.html"><img src="images/H0m2.jpg" alt="" name="Image2" align="top" onmouseover='document.getElementById("about_us").v isibility="visible"; makeHidden("about_us");' /></a>[/HTML]

So the idea is to display a <div> menu while toggling the other menus to "hidden";
Newbie
 
Join Date: Jan 2008
Posts: 2
#2: Jan 19 '08

re: document.getElementById(toggle[i]) has no properties


I figured it out.

The problem code:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('about_us').visibility='visible';
The solution code:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('about_us').style.visibility='visible';
I left out style.

Funny how that took me 45 minutes to see. ARRRG!
Reply