get value of checked[ALL] or unchecked box jquery
- by python
I have read this.
http://stackoverflow.com/questions/2048485/jquery-checkbox
<input type="checkbox" name="checkGroup" id="all">
<input type="checkbox" name="checkGroup" id="one" value="1">
<input type="checkbox" name="checkGroup" id="two" value="2">
<input type="checkbox" name="checkGroup" id="three" value="3">
<input type="hidden" name="storeCheck" value="">
$(function(){
$("#all").click(function(){
$("input:checkbox[name='checkGroup']").attr("checked",$(this).attr("checked"));
});
$("input:checkbox[name='checkGroup']:not('#all')").click ( function(){
var totalCheckboxes = $("input:checkbox[name='checkGroup']:not('#all')").length;
var checkedCheckboxes = $("input:checkbox[name='checkGroup']:not('#all'):checked").length;
if ( totalCheckboxes === checkedCheckboxes )
{
$("#all").attr("checked" , true );
}
else
{
$("#all").attr("checked" , false );
}
});
});
Demo
I am trying to get the value of the checkboxs are checked as an array.
for example
if I checked All
Get value array_check = 1,2,3 and passed this array to hidden name="storeCheck"
otherwise:
Get value of array_check( checkboxs checked ).and passed this array to hidden name="storeCheck"