dimanche 20 novembre 2016

Ajax with mysql and checkboxes

I have checkboxes on my page for which I would like to send their state to the database via ajax. Everything works with SELECT and OPTIONS, but I don't know to do the same things with several checkboxes and how to get the value from them.

The data retrived only for one checkbox?when I change checkbox it doen't work

Any ideas?

my code looks like this->

       <form>
          <div class="checkbox" >
            <label><input type="checkbox" value="1" calss="item">что то</label>
            <label><input type="checkbox" value="1" calss="item">Шорты</label>
            <label><input type="checkbox" value="3" class="item">Классическая</label>
          </div>
</form>



 <script>
$(document).ready(function () {
$('.item').on('click',function(){


    var name = $('.item').val();
    $.post('load.php', {name:name}, function(data){
        $('#name-data').html(data);
    });
});

});
</script>




Aucun commentaire:

Enregistrer un commentaire