hai,
i want to select only parent checkbox. then automatically check all child checkboxes. i mean checkall checkboxes at once. using javascript

<SCRIPT LANGUAGE = "JavaScript">
<!--

function modify_boxes(to_be_checked,total_boxes){
 for ( i=0 ; i < total_boxes ; i++ ){
   if (to_be_checked){  
 document.forms[0].chkboxarray[i].checked=true;
}
   else{
   
document.forms[0].chkboxarray[i].checked=false;
   }
 }  
}
   
-->
</SCRIPT>


<BODY>
<FORM>
<INPUT TYPE=checkbox NAME="chkboxarray" VALUE="1"><br>
<INPUT TYPE=checkbox NAME="chkboxarray" VALUE="2"><br>
<INPUT TYPE=checkbox NAME="chkboxarray" VALUE="3"><br>
<INPUT TYPE=checkbox NAME="CheckAll" VALUE="Check All Boxes" onClick="modify_boxes(true,3)">check all

</FORM>
</BODY>

it does not working. anybody help plz.

<html>
<head>

<script language="javascript">


function checkAll() {
for (var j = 1; j <= 14; j++) {
box = eval("document.checkboxform.C" + j); 
box.checked = !box.checked;
   }
}
</script>
</head>
<body>
<form name=checkboxform>
<input type=checkbox name=C1 >C1<br>
<input type=checkbox name=C2 >C2<br>
<input type=checkbox name=C3 >C3<br>
<input type=checkbox name=C4 >C4<br>
<input type=checkbox name=C5 >C5<br>
<input type=checkbox name=C6 >C6<br>
<input type=checkbox name=C7 >C7<br>
<input type=checkbox name=C8 >C8<br>
<input type=checkbox name=C9 >C9<br>
<input type=checkbox name=C10 >C10<br>
<input type=checkbox name=C11 >C11<br>
<input type=checkbox name=C12 >C12<br>
<input type=checkbox name=C13 >C13<br>
<input type=checkbox name=C14 >C14<br>
<br>

<input type=checkbox value="Switch All" onClick="checkAll()"> selectall<br>
</form>


</body>
</html>

try this code. i hope u are trying for this one only.

<html>
<head>

<script language="javascript">


function checkAll() {
for (var j = 1; j <= 14; j++) {
box = eval("document.checkboxform.C" + j); 
box.checked = !box.checked;
   }
}
</script>
</head>
<body>
<form name=checkboxform>
<input type=checkbox name=C1 >C1<br>
<input type=checkbox name=C2 >C2<br>
<input type=checkbox name=C3 >C3<br>
<input type=checkbox name=C4 >C4<br>
<input type=checkbox name=C5 >C5<br>
<input type=checkbox name=C6 >C6<br>
<input type=checkbox name=C7 >C7<br>
<input type=checkbox name=C8 >C8<br>
<input type=checkbox name=C9 >C9<br>
<input type=checkbox name=C10 >C10<br>
<input type=checkbox name=C11 >C11<br>
<input type=checkbox name=C12 >C12<br>
<input type=checkbox name=C13 >C13<br>
<input type=checkbox name=C14 >C14<br>
<br>

<input type=checkbox value="Switch All" onClick="checkAll()"> selectall<br>
</form>


</body>
</html>

try this code. i hope u are trying for this one only.

oh....thnks for ur help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.