0

I have this html table with input cells...i am able to get subtotal and actual total from the input values...however i would love to add comma to this generated values...these are my codes below

Picture pictures showing the input and generated values

this adds comma to my input cell:

$('input.number').keyup(function(event) {
   if(event.which >= 37 && event.which <= 40) return;
  // format number
  $(this).val(function(index, value) {
    return value
    .replace(/\D/g, "")
    .replace(/\B(?=(\d{3})+(?!\d))/g, ",")
    ;
  });
});

This generates my dynamic values

$(document).ready(function(){
    $('.qtyorder').on("keyup change",function(){
        update_amounts();
    });
});

function update_amounts(){
    var sum = 0.0;
    $('#id > tbody  > tr').each(function(){

        var qty = parseFloat($(this).find('.qtyorder').val().replace(/\,/g,''))||0;
        var amount = (qty)

        if (amount > 0) {`enter code here`
            $(this).find('.subtotal').val(amount);
            sum = sum + amount;

        } else {
            $(this).find('.subtotal').val("0.00");
        }
    });

    if (sum > 0) $('.ordertotal').val(sum);

    else $('.ordertotal').val("0.00");
}

0 Answers0