mardi 26 septembre 2017

Display selected value from input in front end?


Hi All,

I have a slider, which each of them has different input.

Im'trying to dispaly in the front end each value of the input selected for each slide via:

var ckbox = $(".flexbox-container input");
    var chkId = '';
    $('input').on('click', function() {

      if (ckbox.is(':checked')) {
        $("flexbox-container input:checked").each ( function() {
                 chkId = $(this).val() + ",";
          chkId = chkId.slice(0, -1);
         });

         document.getElementById("score").innerHTML = ( $(this).val() )

      }     
    });

It works fine on the first slide, but then not any value display in the other slides.

However, if I use this code:

var ckbox = $(".flexbox-container input");
    var chkId = '';
    $('input').on('click', function() {

      if (ckbox.is(':checked')) {
        $("flexbox-container input:checked").each ( function() {
                 chkId = $(this).val() + ",";
          chkId = chkId.slice(0, -1);
         });

          alert ( $(this).val() ); // return all values of checkboxes checked
         alert(chkId); 
      }     
    });

each value appear correctly for each slide in the alert box ...

Any help will be super for this !

Thanks a lot !




Aucun commentaire:

Enregistrer un commentaire