Ciao,
ho il seguente problema:
devo creare una checkbox che mi permette di selezionare tutte le checkbox presenti caricate dinamicamente.
Ho scritto così:
codice:
<script type="text/javascript">
$(document).ready(function() {
$('#selecctall').click(function(event) { //on click
if(this.checked) { // check select status
$('.checkbox1').each(function() { //loop through each checkbox
this.checked = true; //select all checkboxes with class "checkbox1"
$('#DIVselecctall span').addClass('checked');
$('#DIVcheckbox1 span').addClass('checked');
});
}else{
$('.checkbox1').each(function() { //loop through each checkbox
this.checked = false; //deselect all checkboxes with class "checkbox1"
$('#DIVselecctall span').removeClass('checked');
$('#DIVcheckbox1 span').removeClass('checked');
});
}
});
});
</script>
<div id="DIVselecctall" class="checker">
<span class="">
<input type="checkbox" id="selecctall" title="seleziona tutti"/>
</span>
</div>
<?php
echo "<div id='DIVcheckbox1' class='checker'><span class='' >";
echo "<input class='checkbox1' type='checkbox' name='checkConferme[]' value='$rID' onclick='checkME(this)'>";
echo "</span></div>";
echo "<div id='DIVcheckbox1' class='checker'><span class='' >";
echo "<input class='checkbox1' type='checkbox' name='checkConferme[]' value='$rID' onclick='checkME(this)'>";
echo "</span></div>";
echo "<div id='DIVcheckbox1' class='checker'><span class='' >";
echo "<input class='checkbox1' type='checkbox' name='checkConferme[]' value='$rID' onclick='checkME(this)'>";
echo "</span></div>";
?>
Il codice mi funziona correttamente quando seleziono SelectALL mi seleziona tutti, ma non funziona se voglio deselezionare una check dopo che ho selezionato tutti.
Grazie per il supporto.