samedi 19 septembre 2015

Get values from all checkboxes with JS

I have N-* number checkbox, on every page, it is always different. I use the plugin js: iCheck.

The problem at the level checked in the checkbox to send via js its value. if marked 5, 8 and 9, the value must be:

5 8 9

I also get to get the value of only one, the last marked checkbox, even if marked at least 10 pieces.

My JS code:

   $('.iCheck').on('ifChecked', function(event){
    var checkedValue = $(this).attr('value');
    alert(checkedValue);
    var itemsbought = document.getElementById(checkedValue).innerHTML;
    $('.gds-buy-items-bought').html('<div class="item">'+itemsbought+'</div>');
    });

Code:

$('.gds-buy-items-bought').html(''+itemsbought+'');

Works only 1 time 1 value. And i need to load all values and as many times as I have mentioned checkbox is ..

I suffer a half hours already and tried to shove cycles until no chance.




Aucun commentaire:

Enregistrer un commentaire