PDA

View Full Version : JS problem



crasty
10-24-2007, 04:07 PM
im a n00b and i made this little script:


var menu_value = new Array('login','panel','show','search','support','stats');
var i;

for (i = 0; i < menu_value.length; i++)
{
document.getElementById(menu_value[i]).style.display = 'none';
}
document.getElementById(menu_value[1]).style.display = 'block';
but document.getElementById functions stop the execution of the code. Why? thk :)

jscheuer1
10-24-2007, 04:14 PM
If you do not have one and only one element on the page for each of the id values in your array, that would cause an error. Even if you do, but the code runs before the browser has parsed all of the elements, you will get an error. If you need more help:

Please post a link to the page on your site that contains the problematic code so we can check it out.

crasty
10-24-2007, 04:16 PM
oh yes i dont remember to add the last element of the array :/ thk :P