[thelist] Another basic JavaScript question
john at johnallsopp.co.uk
john at johnallsopp.co.uk
Sat Oct 18 10:35:03 CDT 2003
Nope, still brain dead, so here's another (I do find the very basics
sometimes the most difficult, you can always look up a function, but a
question like this one is more difficult to find the answer to).
OK, I have this
function menu2(menu1)
{
menu2 = new Array (7, 7);
menu2[1, 0]="";
menu2[1, 1]="Why change?";
menu2[1, 2]="What type?";
menu2[1, 3]="";
menu2[1, 4]="";
menu2[1, 5]="";
menu2[1, 6]="";
for (c=1; c<=2; c++)
{
var myElement = "m2" + c;
alert (myElement);
alert (menu2[1,3]);
getElementById(myElement).firstChild.nodeValue="Donkey";
}
}
which is intended to populate the second row of a menu based on a rollover
on the first row. It's only set up to do this for the first menu choice at
the moment, there'll be others for menu2[2, n] etc. later.
Anyway, the for loop goes around once and stops on the getElementById
line, even though that works when it's not in the function. "Donkey" will
be replaced by menu2[menu2, c] once it's working.
It throws, first of all, menu2 is not a function, then getElementById is
not defined. I take that to mean that myElement is not being expanded to
its value which is set correctly according to the alert. Am I right, and
if so, how do I get it to replace myElement with m21, m22, etc.?
Thanks in advance for your help.
Cheers
J
More information about the thelist
mailing list