fix checked box
This commit is contained in:
@ -445,32 +445,61 @@
|
|||||||
|
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
|
|
||||||
|
// alert($(this).index());
|
||||||
|
|
||||||
if ($(this).is(':checked')) {
|
if ($(this).is(':checked')) {
|
||||||
// Checkbox is checked, add value to the array
|
// Checkbox is checked, add value to the array
|
||||||
selectedValues.push(value);
|
selectedValues.push(value);
|
||||||
} else {
|
} else {
|
||||||
// Checkbox is unchecked, remove value from the array
|
var value = $(this).val();
|
||||||
var index = selectedValues.indexOf(value);
|
var allvall = $("input[name=acc_no]").val();
|
||||||
if (index !== -1) {
|
var arrVal = allvall.split(',');
|
||||||
selectedValues.splice(index, 1);
|
|
||||||
|
$.each(arrVal, function(index, val){
|
||||||
|
if (val != value) {
|
||||||
|
arrVal.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
selectedValues.push(arrVal);
|
||||||
|
// let index = array.indexOf(elementToRemove);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Checkbox is unchecked, remove value from the array
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Display the selected values (just for demonstration)
|
// Display the selected values (just for demonstration)
|
||||||
$('.selected-values').val(selectedValues.join(','));
|
$('input[name=acc_no]').val(selectedValues);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var arr = [];
|
var arr = [];
|
||||||
$("#selectAll").on('click', function() {
|
$("#selectAll").on('click', function() {
|
||||||
$('.exportPdf').show();
|
$('.exportPdf').show();
|
||||||
|
|
||||||
|
if ( $(this).prop('checked')) {
|
||||||
|
arr.splice(0, arr.length);
|
||||||
$("input[type=checkbox]").prop('checked', $(this).prop('checked'));
|
$("input[type=checkbox]").prop('checked', $(this).prop('checked'));
|
||||||
$.each($("input[name='account_number']:checked"), function() {
|
$.each($("input[name='account_number']:checked"), function() {
|
||||||
arr.push($(this).val());
|
arr.push($(this).val());
|
||||||
$("input[name=acc_no]").val(arr)
|
$("input[name=acc_no]").val(arr)
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
arr.splice(0, arr.length);
|
||||||
|
$("input[type=checkbox]").prop('checked', false);
|
||||||
|
$.each($("input[name='account_number']"), function() {
|
||||||
|
// arr.push($(this).val());
|
||||||
|
$("input[name=acc_no]").val('')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user