Munish Rana

Munish Rana

  • 2k
  • 3
  • 375

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();
            });
        });

Brought to you by:

Answers (1)