The problem i am facing is that i do not know how many yes/no radio groups
will be generated
Your validation function has to loop through all the form elements, then, and
check them against type==radio. This assumes all radio elements are part of
this check.
Note that document.forms is an array that has a property called elements that
is an array.
document.forms['formname'].elements[]
or
document.forms[index].elements[]
or
document.formname.elements[] (shortcut syntax may not work in all browsers)
(you get the idea)
There are a couple other ways to do this that are not as cross-browser (i.e.
require newer DOM methods such as getElementsByTagname, getElementsByName, or
getElementById). If you only need to support newer browsers, you can do
something like name them all consistently (i.e. all named optiongroupname_x
where x is an integer), write the final value of x to a javascript variable,
and do a looped getElementsByName("optiongroupname"+x).
The first is simpler. If you have a LOT of form elements that are NOT part of
the option groups you're interested in, though, the second can save you
processing time by resulting in a smaller loop. Since JS runs on the client,
the time it takes to do things is highly dependent on the user's machine.
Sometimes it's worth it to try to optimize things that loop.
--
--
~kaeli~
Frisbeetarianism (n.), The belief that, when you die, your
soul goes up on the roof and gets stuck there.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace