Click to See Complete Forum and Search --> : Can anyone help with this?


tomwoj
03-13-2003, 08:34 AM
This function won't run when I use spot in style.display line. I know it's making the correct name as I tested it with the alert. If I hardcode in one of the ID's it generating that part of it works fine. Does anyone know how to fix my problem.

function showall(){
var i = 1;
do
{
var spot;
spot = 'menu'+i+'outline';
alert(spot);
spot.style.display='';
i+=1;
}
while(i<5);
}

thanks
tom

gil davis
03-13-2003, 10:05 AM
You are confusing objects and strings. Your var "spot" is just a string, not an HTML object. If you post the correct object identifier, someone should be able to help you.

tomwoj
03-13-2003, 10:14 AM
What I'm doing is making a show all for a collapsable menu that we have. The elements in it are named in numerical progression menu1outline, menu2outline, etc. All I wanted this to do is run through x numbers and make all of those elements visible. I hope that helps you answer my question.

gil davis
03-13-2003, 10:19 AM
NS 4:document.layers[spot].display
IE 4:document.all[spot].style.display
IE 5+ and NS 6+:document.getElementById(spot).style.display

tomwoj
03-13-2003, 11:46 AM
Thanks Gill that fixed it. :p