计算合计

//计算合计
        sumTotal:function(){
            var inputs = document.getElementById("FinancialPaymentList").getElementsByTagName("input");
            //var rows = "";
            if (inputs.length == 0) {
                $.dialog.alert("请选择要计算的数据");
                return;
            }
            var sumzhifu = 0,sumshifu = 0;
            for (var i = 0; i < inputs.length; i++) {
                if (inputs[i].type == "checkbox") {
                    if (inputs[i].checked) {
                        sumzhifu += Number($(inputs[i]).attr('zhifu'));
                        sumshifu += Number($(inputs[i]).attr('shifu'));
                        //rows += inputs[i].value + ",";
                    }
                }
            }

            $("#sumzhifu").html(sumzhifu.toFixed(2));//支付
            $("#sumshifu").html(sumshifu.toFixed(2));//实付
            //console.log(rows)
        },

获取所有input标签,再筛选出被勾选的,然后累加变量,再给元素赋值

猜你喜欢

转载自www.cnblogs.com/liufeiran/p/12613999.html