When i uncheck the checkbox the appended value isn't removed from the list
var checkarr = [];
var getdata =[];
$("input[type=checkbox]").on( "click", function() {
var pushdata = $(this).val();
var atLeastOneIsChecked = $('#filter :checkbox:checked').length > 0;
if (atLeastOneIsChecked )
{
checkarr.push(pushdata);
$('.data').addClass(pushdata);
}
else
{
var getval = $.inArray( pushdata, checkarr );
delete checkarr[getval];
$('.data').removeClass(pushdata);
}
var passval = $.unique(checkarr);
$.ajax({
type: "POST",
url: "check.php",
data: {filterOpts: passval},
success: function(records)
{
var dataval = JSON.parse(records);
$.each(dataval,function(k,v) {
getdata.push(v);
var finddata = $('.data').append('<tr><td>'+v+'</td></tr>');
$('.data').show();
});
}
});
});
Aucun commentaire:
Enregistrer un commentaire