mercredi 22 janvier 2020

count qty in checked row and update div element

enter image description here

I made a div to display counted qty (Total)

<div style='font-size:18px;'>Total : <div id='total_qty_chk' style='display:none' value=''></div> </div>

And I made a jquery to count every checked checkbox in any row,

  $(document).ready(function() {

var total_qty_chkd = document.getElementbyId('#total_qty_chk'); //display count
total_qty_chkd.value = 0;
var chkqty1 = document.getElementsByClassName('txtbtsclass'); //qty value saved here


    $("input:checkbox").on("change", function () { //when clicked

        $.each($("input[id='chkajax']:checked"), function(){    //count every clicked checkbox        
            Number(total_qty_chkd.value) = Number(total_qty_chkd.value) + Number(chkqty1.value);
        });
        total_qty_chkd.toggle();

    });


});

For Example when I clicked the first and the second checkbox, Total will show value 36.8

Can someone help me solve this? Any help would be appreciated.




Aucun commentaire:

Enregistrer un commentaire