[thelist] javascript dynamic loop

Matt Warden mwarden at gmail.com
Tue Nov 29 21:53:46 CST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brian Cummiskey wrote:
> for (j=1; j=numkids; j++)

I think you want this to be:

for (j=1; j<=numkids; j++)

But you have other problems, too.

> age = eval("childage_"+j);
> kidage = theform.age.value;

This isn't doing what you think it is. This is trying to access a field
named "age", whereas you think it's accessing a field named whatever the
value of the age variable is.

Try:

kidage = theform.elements[ "childage_" + j ].value;

- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDjSJKrI3LObhzHRMRAjhCAKCAoKlhn9hZTN6nN7DmYRO1iuKGpQCguzQE
r69YMTSsCM/2gMkXmVA9Crw=
=I6DU
-----END PGP SIGNATURE-----



More information about the thelist mailing list