JQuery checkbox manipulation within a foreach loop
JQuery checkbox manipulation within a foreach loop
HTML
<th><input type="checkbox" id="checkAll"/> Select All</th>
<input type="checkbox" class="checkbox" value="1" >
<input type="checkbox" class="checkbox" value="2" >
<input type="checkbox" class="checkbox" value="3" >
<input type="checkbox" class="checkbox" value="4" >
<input type="checkbox" class="checkbox" value="5" >
<button class="btn btn-success btn-flat pull-right" id="btn-distribute-profit" >
<i class="fa fa-free-code-camp"></i> Distribute
</button>
JavaScript
$('#checkAll').click(function (event) {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
$('#btn-distribute-profit').on('click',function(){
var result = $('input[type="checkbox"].checkbox:checked')
test = 0
result.each(function () {
test = 1
});
if(test == 1)
{
alert("Calculation Done");
location.reload();
}else{
alert("No Performance records");
}
});