I have a switch statement that controls which of several containers is
displayed or not. It currently looks like:
function showHelp(n) {
show('vhelp'); //makes parent container visible
switch (n){
case 0:
show('image0');hide('image1');hide('image2');...;h ide('imagem');
break;
..
..
case m:
show('imagem');hide('image0');...;hide('imagem-1');
}
The functions show('target') and hide('target') are simple js functions,
i.e., : document.getElementById(target).style.display = "" //(or "none")
I want to change the lengthy show/hide strings. I've tried using
variations to name the appropriate containers in the function:
function xImages (n) {
for(var i=0; i <m+1; i++) { //I hard enter m+1
if (i==n) {document.form1.elements["image"+(i)].style.display="";}
else {document.form1.elements["image"+(i)].style.display='none';}
}
I get the error msg message:
Could not convert undefined or null to object
document.form1.elements[("image" + i)].style.display = "none";
Apparently I'm not addressing the container properly, but I can't comeup
with the correct syntax. HELP! Please.
--
Ed Jay (remove 'M' to respond by email)