Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question with document property

Status
Not open for further replies.

raylit

Programmer
Sep 8, 2000
2
US
Hi guys,

I need help in a form which is checkbox form.

I have a dynamic form which will create n number of checkboxes( default checked) & I have a button (Clear All)
which should uncheck the checkboxes....
so I want to create i in below expression as dynamic...
document.a.Ci.checked = false;

How to do it???

document.a.C1.checked = false;
document.a.C2.checked = false;
document.a.C3.checked = false;
document.a.C4.checked = false;
document.a.C5.checked = false;
...................


Please help......
Thanks in advance,

Raylit


[sig][/sig]
 
Ray,

Use javascript (this one works with IE 4+ and NN6, didn't test on NN4)...

Code:
<html>
<head>
<script language=&quot;javascript&quot;>
 function fnCheckMode(mode){
  var max=6
  for (var i=1;i<=max;i++){
   if (mode==1){
    eval(&quot;document.forms.frmForm.C&quot; + i + &quot;.checked=true&quot;);
   }
   else{
    eval(&quot;document.forms.frmForm.C&quot; + i + &quot;.checked=false&quot;);
   }
  }
 }
</script>
<body>
<form id=frmForm name=frmForm>
Checkbox 1<input type=checkbox id=C1 name=C1 checked><br>
Checkbox 2<input type=checkbox id=C2 name=C2 checked><br>
Checkbox 3<input type=checkbox id=C3 name=C3 checked><br>
Checkbox 4<input type=checkbox id=C4 name=C4 checked><br>
Checkbox 5<input type=checkbox id=C5 name=C5 checked><br>
Checkbox 6<input type=checkbox id=C6 name=C6 checked><br>
<input type=button onClick=&quot;fnCheckMode(1)&quot; value=&quot;Check all&quot;>&nbsp;&nbsp;
<input type=button onClick=&quot;fnCheckMode(0)&quot; value=&quot;Clear all&quot;>
</form>
</body>
</html>

Hope this helps,
[sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Thanx Rob for the help....

document.a[ [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top