[Javascript] simple array
Thomas Wheeler
Tomw at c-techindustries.com
Wed May 2 19:08:49 CDT 2001
Trying to learn, if I have a series of variables like content1, content2, etc.. and I want to cycle through them
can I write a for loop? Here's my current code:
if (obj != content1) hide(content1);
if (obj != content2) hide(content2);
if (obj != content3) hide(content3);
if (obj != content4) hide(content4);
if (obj != content5) hide(content5);
if (obj != content6) hide(content6);
Here's what I've been trying to do:
function show(obj) {
//show the obj here
for(i = 1; i < 7; i++)
if (obj != content + [i]) hide(content + [i]);
}
this doesn't work, and other variations of it I've tried are also unsuccessful. I know I could list all the variables, but isn't there a more concise way?
Tom Wheeler
More information about the Javascript
mailing list