Code: Select all
<form name="myform" action="" method="post">
<div id="course1">
Bob<input type="checkbox" name="course[]" value="bob" />
Charles<input type="checkbox" name="course[]" value="charles" />
John<input type="checkbox" name="course[]" value="john" />
<input type="button" name="check_all" value="Check All" onClick="CheckAll(document.getElementsByName('course[]'))" />
</div>
<input type="submit" />
</form>Code: Select all
function CheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}How can I check all the checkboxes which are inside the div with the id="course1"?
I will have more divs with id="course2", "course3" etc.
Any help would be appreciated.