Page 1 of 1

javascript แปลง string เป็น number จุดทศนิยม 2 ตำแหน่ง

Posted: 23/01/2019 5:56 pm
by jataz2

Code: Select all

function sumTotalAmount() {
            var totalAmount = 0.00;
            var transactionAmount = 0;
            
            $("#table_search_result tbody tr").each(function () {
                transactionAmount =  $(this).find('td:eq(2)').html();

                totalAmount = Number(Number(totalAmount) + Number(transactionAmount)).toFixed(2);
            });
            var trow ='<tr><td></td><td><u>สุทธิ</u></td><td>'+totalAmount+'</td><td></td></tr>';
            $("#table_search_result tr:last").after(trow);
        }