表格平均值计算
$("#kong input").blur(function(a){ //var tnm = $(a.target).attr('name'); Getlmpj(); }); function Getlmpj() { var avg = 0; var num1 = ChangeFloat($("#kongcuTr1C").val()); var num2 = ChangeFloat($("#kongcuTr2C").val()); var num3 = ChangeFloat($("#kongcuTr3C").val()); var num4 = ChangeFloat($("#kongcuTr4C").val()); var num5 = ChangeFloat($("#kongcuTr5C").val()); var num6 = ChangeFloat($("#kongcuTr6C").val()); if (num1 != 0 && num2 != 0 && num3 != 0 && num4 != 0 && num5 != 0 && num6 != 0) { avg = (num1 + num2 + num3+num4+num5+num6) / 6; $("#kongcuTraveC").val(RoundValue(avg,2)); } } function RoundValue(avg,num){ return Math.round(avg*Math.pow(10,num))/ Math.pow(10, num); } function ChangeFloat(data) { if (data != null && data != "") { return parseFloat(data); } else { return 0; } }
#kong ~id