Munish Rana

Munish Rana

  • NA
  • 3
  • 651

Sum is coming in (-) and value is adding up

Feb 3 2018 2:50 PM
    $(function() {
            //mask
        $('#total_payment,#deductions').mask('#,##,##,###',{reverse : true});
            //function that will get the total amount by each class
            var net_payable = function() {
                var sum=0;
                $('#total_payment,#deductions').each(function(){
                    var num = $(this).val().replace(',','');
                    
                    if(num != 0) {
                        sum -= parseFloat(num);
                    }
                });
                $('#net_payable').val(sum);
            }
            //key handler
            $('#total_payment,#deductions').keyup(function(){
                net_payable();
            });
        });

Answers (1)