mardi 15 décembre 2015

Store an array value in jQuery from checkbox

Hye,

Been trying to do this but still with no solution. I want to store an Input checkbox with array from a form and post the value of the selected checkbox using jQuery for delete purpose. I'm unable to get the checkbox value when user make the selection more than 1. May I know the right way to store an array value using jQuery. Below are the codes for html checkbox:

<input type="checkbox" name="checkBox[]" id="checkBox" value='".$row['staff_id']."'>

and this are the jQuery:

$(document).ready(function() {
$("#del").click(function(){
    var del = $("#del").val();
    var checkBox = $("#checkBox:checked").val();
    $.post('admin_cuti/staff-delete.php',
    {
        del : del,
        checkBox : checkBox
    }, function(data){
        $("#result_del").html(data)
       });  
    });
});




Aucun commentaire:

Enregistrer un commentaire