You are viewing limited content. For full access, please sign in.

Question

Question

Prorating Total in Dynamic Tables

asked on October 19, 2015

I'm using the following JavaScript to prorate the Total from multiple dynamic tables and it works perfectly fine. However, as they are dynamic tables, once a row is filled the total is calculated. But when the row is deleted, the total is not subtracting the deleted row value.

Can anyone help with this?

 

            $('select').prop('required', true);
            $('.cf-table-block').on('blur change', '.amnt input', sumtotal);

            function sumtotal() {
                var s = 0;
                $('.amnt input').each(function() {
                    s += parseNumber($(this).val());
                });
                $('#Field128').val((s).toFixed(2));
            }

            function parseNumber(n) {
                var f = parseFloat(n); //Convert to float number.
                return isNaN(f) ? 0 : f; //treat invalid input as 0;
            }

 

1 0

Answer

SELECTED ANSWER
replied on October 19, 2015

You can add the line

$(document).on('click', '.form-del-field', sumtotal);

This will run the sumtotal function whenever a row is deleted from the table.

1 0
replied on October 20, 2015

Thanks you!

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.