js求和

function GetTotal() {
            var traveltotal = document.getElementById("ctl00_PlaceHolderMain_lstTravel_txtTravelReportTotal").value;
            var DailyTotal = document.getElementById("ctl00_PlaceHolderMain_lstDaily_txtDailyReportTotal").value;
            var OthersTotal = document.getElementById("ctl00_PlaceHolderMain_lstExpenseBusiness_txtOthersTotal").value;
            var total = document.getElementById("ctl00_PlaceHolderMain_txtTotalExpense").value;
            traveltotal = parseFloat(traveltotal.replace(/,/g, ""));
            DailyTotal = parseFloat(DailyTotal.replace(/,/g, ""));
            OthersTotal = parseFloat(OthersTotal.replace(/,/g, ""));//去除千分位
            if (!isNaN(traveltotal))
                total = traveltotal;
            if (!isNaN(DailyTotal))
                total = total + DailyTotal;
            if (!isNaN(OthersTotal))
                total = total + OthersTotal;
            document.getElementById("ctl00_PlaceHolderMain_txtTotalExpense").value = total.toFixed(2);
            Change();
        }
        function Change() {
            var Cashtotal = document.getElementById("ctl00_PlaceHolderMain_txtCash").value;
            var total = document.getElementById("ctl00_PlaceHolderMain_txtTotalExpense").value;
            total = parseFloat(total.replace(/,/g, ""));
            Cashtotal = parseFloat(Cashtotal.replace(/,/g, ""));
            var differential
            if (!isNaN(total)) {
                if (!isNaN(Cashtotal)) {
                    differential = total - Cashtotal;
                    differential = parseFloat(differential);
                    if (differential < 0) {
                        document.getElementById("ctl00_PlaceHolderMain_txtDUEASIMCO").value = -differential.toFixed(2);
                        document.getElementById("ctl00_PlaceHolderMain_txtDUEEMPLOYEE").value = "";
                    }
                    else {
                        document.getElementById("ctl00_PlaceHolderMain_txtDUEASIMCO").value = "";
                        document.getElementById("ctl00_PlaceHolderMain_txtDUEEMPLOYEE").value = differential.toFixed(2);
                    }
                }
            }
        }

posted @ 2013-04-26 10:50  717806198  阅读(254)  评论(0)    收藏  举报