Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
117
rated 0 times [  123] [ 6]  / answers: 1 / hits: 31294  / 13 Years ago, thu, july 14, 2011, 12:00:00

I have a table with checkboxes and I want to do the check all and un-check all checkboxes but I could not find the way to check all the checkboxes.



Here is my code:



<form>
<?php foreach ($this->entries as $entry): ?>
<tr class=table_head_seperator>
<td class=grid_info width=32px bgcolor=#f6f6f6><input type=checkbox class=chk_boxes1 name=to_delete[<?PHP echo $entry['id'] ?>] /></td>
<td class=grid_info width=160px bgcolor=#eeeeee><span class=country_name><?php echo $entry['user_name'] ?></span></td>
<td class=grid_info width=130px bgcolor=#eeeeee><span class=country_name><?php echo $entry['date_created'] ?></span></td>
<td class=grid_info width=100px bgcolor=#f6f6f6><span class=country_name><?php echo $entry['user_type_name'] ?></span></td>
</tr>
<?PHP endforeach; ?>

<input type=checkbox class=chk_boxes label=check all />check all
<input type=checkbox class=unchk_boxes /> un-check all
</form>
<script type=text/javascript>
$(document).ready(function() {
$('.chk_boxes').click(function(){
$('.chk_boxes1').attr('checked',checked)
})
});
</script>

More From » php

 Answers
14
$(function() {
$('.chk_boxes').click(function() {
$('.chk_boxes1').prop('checked', this.checked);
});
});


This only affects the check all box. But why would you want to use two checkboxes anyway? One to check all and one to uncheck all, but not mutually exclusive. That's got to be the recipe to confuse users :)


[#91189] Tuesday, July 12, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
estefanib

Total Points: 508
Total Questions: 104
Total Answers: 83

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;