better ways?

Giganews Newsgroups
Subject: better ways?
Posted by:  Draken (lord_draken_kor…
Date: Thu, 3 Jul 2003

I have a menu of radio buttons with the name myform (thank you to Evertjan.
for your help with my other problem, I have no idea where the error was but
I worked through it from your advice) pretty much one of them HAS to be
selected (it would be hard to avoid it) and my loop cycles through until if
finds the checked button... as I have no way to tell how many items there
will be in the array of menu items I cant put a static number in the loop,
at the moment I have this....
for(i=0;document.menuform.myform[i] != undefined;i++)

as when you reach say document.menuform.myform[10] and there is no 10th it
will return "undefined", but this doesnt seem to be the best of ways to do
it? Is there any exceptions to this way? Any better ways? I tried while
(document.menuform.myform) thinking that reaching an undefined item would be
'false' but as you can guess i caused an infinite loop :(

So basically is there any better/easier ways to write this loop, and are
there any exceptions to this loop?