0

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.

Edited by muralikalpana: n/a

2
Contributors
2
Replies
7
Views
8 Years
Discussion Span
Last Post by muralikalpana
1
<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.

0
<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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.