Utilizzando alcuni framework come jQuery renderà la vostra vita molto più facile. Supponiamo che segue è la struttura dei record:
<table id="report">
<tr><td> <input type="checkbox" id="tr1" /></td><td>..</td><td>...</td></tr>
<tr><td> <input type="checkbox" id="tr2" /></td><td>..</td><td>...</td></tr>
<tr><td> <input type="checkbox" id="tr3" /></td><td>..</td><td>...</td></tr>
<tr><td> <input type="checkbox" id="tr4" /></td><td>..</td><td>...</td></tr>
<tr><td> <input type="checkbox" id="tr5" /></td><td>..</td><td>...</td></tr>
</table>
<input type="checkbox" id="chkAll"/> Select All.
Il seguente codice (usando jQuery) farà il necessario:
<script type="text/javascript">
$(document).ready(function(){
$("#chkAll").change(function(){
if($("#chkAll").is(":checked")){
$("#report tr td:first-child").find("input:checkbox")
.attr("checked","checked");
}else{
$("#report tr td:first-child").find("input:checkbox")
.attr("checked","");
}
});
});
</script>
EDIT: - in base al codice, provare a sostituire il vostro boxes_checkall funzione con questo codice;
funzione boxes_checkall (a, b) {var CBS = a.getElementsByTagName ( 'ingresso');
for(var i=0;i<cbs.length;i++)
{
if(cbs[i].type.toLowerCase()=='checkbox')
{
cbs[i].checked = b==1;
}
}
}
</script>