Here is a small test which shows it:
Code:
<html>
<head>
<script language="javascript">
function checkAll(table){
for (var i=0;i<document.forms[0].elements.length;i++)
{
var e=document.forms[0].elements[i];
if ((e.name.substring(0,table.length) == table) &&
(e.name.indexOf('allbox') < 0) && (e.type=='checkbox'))
{
e.checked=eval("document.forms[0]."+table+"_allbox.checked");
}
}
}
</script>
</head>
<body>
<form>
<table border="1">
<tr>
<td>
<input type="checkbox" value="on" name="table1_allbox" onclick="checkAll('table1');"/> Check
all<br />
<h3>Fruit</h3>
<input type="checkbox" value="on" name="table1_apples" /> Apples<br/>
<input type="checkbox" value="on" name="table1_oranges" /> Oranges<br/>
<input type="checkbox" value="on" name="table1_bananas" /> Bananas<br/>
</td>
</tr>
<tr>
<td>
<input type="checkbox" value="on" name="table2_allbox" onclick="checkAll('table2');"/> Check
all<br />
<h3>Fruit</h3>
<input type="checkbox" value="on" name="table2_apples" /> Apples<br/>
<input type="checkbox" value="on" name="table2_oranges" /> Oranges<br/>
<input type="checkbox" value="on" name="table2_bananas" /> Bananas<br/>
</td>
</tr>
</table>
</form>
</body>
</html>
as you can see, I had to make a small change to the lookout for the "allbox" check, since at this point there are several allboxes...