function sumRow(tableName, cellName, beginCol, endCol){ var table = document.getElementById(tableName); var cell = document.getElementById(cellName); var rownum = table.rows.length; var colnum = table.rows(0).cells.length; var i = 0; var j = 0; var l = 0; for(i = 0; i < rownum ; i++){ for(j = 0; j < colnum ; j++){ if( table.rows(i).cells(j).id == cell.id){ l = i; break; } } } var total = 0; for( var k = beginCol ; k < endCol + 1 ; k++ ){ if(!isNaN(parseFloat(trim(table.rows(l).cells(k).innerHTML)))){ total = total + parseFloat(trim(table.rows(l).cells(k).innerHTML)); } } cell.innerHTML = total; } function sumCol(tableName, cellName, beginRow, endRow){ var table = document.getElementById(tableName); var cell = document.getElementById(cellName); var rownum = table.rows.length; var colnum = table.rows(0).cells.length; var i = 0; var j = 0; var l = 0; for(i = 0; i < rownum ; i++){ for(j = 0; j < colnum ; j++){ if( table.rows(i).cells(j).id == cell.id){ l = j; break; } } } var total = 0; for( var k = beginRow ; k < endRow + 1 ; k++ ){ if(!isNaN(parseFloat(trim(table.rows(k).cells(l).innerHTML)))){ total = total + parseFloat(trim(table.rows(k).cells(l).innerHTML)); } } cell.innerHTML = total; } function sumRows(tableName, resultCol, resultBeginRow, beginCol, resultEndRow, endCol){ var table = document.getElementById(tableName); for(var i = resultBeginRow ; i <= resultEndRow ; i++){ var cell = table.rows(i).cells(resultCol); var total = 0; for( var k = beginCol ; k <= endCol ; k++ ){ if(!isNaN(parseFloat(trim(table.rows(i).cells(k).innerHTML)))){ total = total + parseFloat(trim(table.rows(i).cells(k).innerHTML)); } } cell.innerHTML = total; } } function sumCols(tableName, resultRow, beginRow, resultBeginCol, endRow, resultEndCol){ var table = document.getElementById(tableName); for(var i = resultBeginCol ; i <= resultEndCol ; i++){ var cell = table.rows(resultRow).cells(i); var total = 0; for( var k = beginRow ; k <= endRow ; k++ ){ if(!isNaN(parseFloat(trim(table.rows(k).cells(i).innerHTML)))){ total = total + parseFloat(trim(table.rows(k).cells(i).innerHTML)); } } cell.innerHTML = total; } } function tableAppendRow(tableName, cellTextArr){ var table = document.getElementById(tableName); var newRow = table.insertRow(); for(var i = 0 ; i < cellTextArr.length ; i++){ var newCell = newRow.insertCell(); newCell.innerHTML = cellTextArr[i]; } } function tableAppendRow(tableName, cellTextArr, rowid){ var table = document.getElementById(tableName); var newRow = table.insertRow(); newRow.id = rowid; for(var i = 0 ; i < cellTextArr.length ; i++){ var newCell = newRow.insertCell(); newCell.innerHTML = cellTextArr[i]; } } function tableInsertRow(tableName, cellTextArr, i){ var table = document.getElementById(tableName); var newRow = table.insertRow(i); for(var i = 0 ; i < cellTextArr.length ; i++){ var newCell = newRow.insertCell(); newCell.innerHTML = cellTextArr[i]; } } function tableInsertRow(tableName, cellTextArr, i, rowid){ var table = document.getElementById(tableName); var newRow = table.insertRow(i); newRow.id = rowid; for(var i = 0 ; i < cellTextArr.length ; i++){ var newCell = newRow.insertCell(); newCell.innerHTML = cellTextArr[i]; } } function truncTable(tableName){ var table = document.getElementById(tableName); var rownum = table.rows.length; for(var i = rownum - 1 ; i > 0 ; i--){ table.deleteRow(i); } } function tableDeleteRow(tableName, i){ var table = document.getElementById(tableName); table.deleteRow(i); } function tableCutRow(tableName){ var table = document.getElementById(tableName); table.deleteRow(table.rows.length - 1); } function highlightRow(row, color) { row.bgColor = color; } function deHighlightRow(row, color) { row.bgColor = color; } function decorateTable(tableName, beginRow, endRow, beginCol, endCol, styleName){ var table = document.getElementById(tableName); var rownum = table.rows.length; var colnum = table.rows(beginRow).cells.length; var _endRow = endRow; var _endCol = endCol; if(endRow > rownum - 1 || endRow == -1){ _endRow = rownum - 1; } if(endCol > colnum - 1 || endCol == -1){ _endCol = colnum - 1; } for(var i = beginRow ; i <= _endRow ; i++){ for( var j = beginCol ; j <= _endCol ; j++){ table.rows(i).cells(j).className = styleName; } } } function highlightTable(tableName, beginRow, endRow, color1, color2){ var table = document.getElementById(tableName); var rownum = table.rows.length; var _endRow = endRow; if(endRow > rownum - 1 || endRow == -1){ _endRow = rownum - 1; } var k = 1; for(var i = beginRow ; i <= _endRow ; i++){ if(k == 1){ table.rows(i).bgColor = color1; k--; }else{ table.rows(i).bgColor = color2; k++; } } } function decorateTable2(tableName, beginRow, endRow, beginCol, endCol, styleName1, styleName2){ var table = document.getElementById(tableName); var rownum = table.rows.length; var colnum = table.rows(beginRow).cells.length; var _endRow = endRow; var _endCol = endCol; if(endRow > rownum - 1 || endRow == -1){ _endRow = rownum - 1; } if(endCol > colnum - 1 || endCol == -1){ _endCol = colnum - 1; } var k = 1; for(var i = beginRow ; i <= _endRow ; i++){ if(k == 1){ for( var j = beginCol ; j <= _endCol ; j++){ table.rows(i).cells(j).className = styleName1; } k--; }else{ for( var j = beginCol ; j <= _endCol ; j++){ table.rows(i).cells(j).className = styleName2; } k++; } } }