<script type="text/javascript">
String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g, "");}
function Statistics() {
var cols = <%=flnumber%>; //定义多少列
/ ar rows = 4;
var tbody1 = document.getElementById('tbody1');//数据区域
var tbody2 = document.getElementById('tbody2');//统计区域
var trs = tbody1.getElementsByTagName('tr');
var results = new Array();
for(var i = 0; i < trs.length; i++){
var cells = trs[i].cells;
results[i] = new Array();
for(var j = 0; j < cells.length; j++){
if(cells[j].innerHTML.trim() == "" || isNaN(cells[j].innerHTML.trim())){
results[i][j] = 0;
} else {
results[i][j] = parseFloat(cells[j].innerHTML.trim());
}
}
}
//开始统计...
var tr = document.createElement("tr");
var td_1 = document.createElement("td");
var td_2 = document.createElement("td");
td_1.innerHTML = "合 计";
td_2.innerHTML = " ";
tr.appendChild(td_1);
tr.appendChild(td_2);
for(var i = 2; i < (cols+2); i++) {
var td = document.createElement("td");
td.className = "mainConTable";
if(i != 0 && i != 1) {
var st = 0;
for(var j = 0; j < trs.length; j++){
st += results[j][i];
}
td.innerHTML = st;
}
tr.appendChild(td);
}
tbody2.appendChild(tr);
}
Statistics();
</script>