lundi 17 juillet 2017

PHP jquery set checkbox value if checked or unchecked and post

I want to set value for the check when it is unchecked. But every time I post my data whatever it is checked or unchecked, the value will be '1'

I tried to set !isset($check) in post.php, but the value also will be 1.

How can I set the different value when I uncheck the checkbox.

<input type="checkbox" id="check" name="check" value="1">

the jquery code is below:

var check = $('#check').val();
var Data = {check:check};
$.ajax({
    type:"POST",
    url:"post.php",
    data:Data,
    beforeSend: function() {
        $("#btn-submit").html('sending');
    },
    success: function(data) {
    }
});




Aucun commentaire:

Enregistrer un commentaire