[Javascript] SPAM-LOW: Checking Radio Boxes with a loop
Terry Bader
bader at tcbader.com
Mon Feb 16 07:26:26 CST 2009
try
eval ("form1.question" + i +".checked=true")
could avoid the eval statement by putting all the questions in the same
group using the name attribute
then
for (i = 0; i < document.myform.list.length; i++)
document.myform.list[i].checked = true ;
can be used
~Terry
----------------------------------------
From: "David Stoltz" <Dstoltz at SHH.ORG>
Sent: Monday, February 16, 2009 8:17 AM
To: javascript at lists.evolt.org
Subject: SPAM-LOW: [Javascript] Checking Radio Boxes with a loop
Hi all,
I have 33 questions on a form, each with YES/NO possibilities. I'm
trying to add a button to "check all" yeses - Here's my code:
I know this is not the right way to do this, and of course it doesn't
work....is there some easy way to dynamically say "question1", then
"question2", etc? If I replace the (i) with a number, it works of
course, and this is the part I'm having trouble with. I didn't want to
do this:
form1.question1[0].checked=true;
form1.question2[0].checked=true;
form1.question3[0].checked=true;
etc....
Any help?
Thanks!
_______________________________________________
Javascript mailing list
Javascript at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript
More information about the Javascript
mailing list