Sunday, 24 November 2013

Grid total column values calculate and display into the label

   function AddTotal() {
        var tot = 0.00;
        $("[id$='txtChargeAmount']").each(function () {
            var sum = $(this).val();
            // alert('sum' + sum);
            sum = sum.replace("$", ''); //Replace  "$"(Doller) with empty string    
            sum = sum.replace(/,/g, '');   //Replace n no of ","(camas) with empty string    

            if (isNaN(sum)) {
                //alert(sum + ' is not a number');
            }
            else {
                if (sum == "") {
                    sum = 0;
                }
                tot += parseFloat(sum);
            }
        });
        //Display the total sum of Values to "txtAmountReceipt" control
        var Total = '$' + tot.toFixed(2);
        $("[id$='lblTotalAmount']").text(Total);
        // $("[id$='hdnTotalAmount']").val(Total);
    }

No comments:

Post a Comment