puoi fare così:
javascript:
Codice HTML:
<script>
function setCheckboxes(the_form, do_check)
{
var elts = (typeof(document.forms[the_form].elements['check[]']) != 'undefined')
? document.forms[the_form].elements['check[]']
:0;
var elts_cnt = (typeof(elts.length) != 'undefined')
? elts.length
: 0;
if (elts_cnt) {
for (var i = 0; i < elts_cnt; i++) {
if (document.forms[the_form].checkall.checked==true) elts[i].checked = true;
else elts[i].checked = false;
}
} else {
elts.checked = do_check;
}
return true;
}
</script>
e nel form:
Codice PHP:
<form action="index.php" method="post" name="delform">
<table>
<tr><td width="200px">Check All ==>
</td><td>
<input name='checkall' type='checkbox' onclick="javascript: return setCheckboxes('delform', true)">
</td></tr>
<?
for($a=0;$a<$n_elementi;$a++){
?>
<tr><td width="200px"><img src="<?=$cartella.$array_file[$a]?>" border="0">
</td><td><input type='checkbox' name='check[]' value='<?=$array_file[$a]?>' id='valida' onclick="">
</td></tr>
<?
}
?>
</table>
<p></p>
<input type="submit" value="Cancella" name="cancella" onclick="javascript: return conferma();">
</form>
e puoi vedere che funziona perfettamente qui:
http://eurosalute.altervista.org/rot...nner/index.php