URGENT: guys i really need your help with this. I have been debugging my program for days but it doesn't seem to be improving
this is the code for the table layout:
<table border="1" id="COT_Table" onclick="getTableID(this)">
<td rowspan="3" scope="row">COT</td>
<th colspan="4" scope="col">SFAL</th>
</tr>
<tr>
<td colspan="2" scope="col">Temperature</td>
<td rowspan="2" scope="row">vol kL@air</td>
<td rowspan="2" scope="row">vol kL@15C</td>
<tr><td>thermo probe</td><td>vessel thermo</td></tr>
</tr>
<tr><td>1P</td><?php TableCells_Temp("COT","1","2");?><?php TableCells2("2");?></tr>
<tr><td>1S</td><?php TableCells_Temp("COT","2","2");?><?php TableCells2("2");?></tr>
<tr><td>2P</td><?php TableCells_Temp("COT","3","2");?><?php TableCells2("2");?></tr>
<tr><td>2S</td><?php TableCells_Temp("COT","4","2");?><?php TableCells2("2");?></tr>
<tr><td>3P</td><?php TableCells_Temp("COT","5","2");?><?php TableCells2("2");?></tr>
<tr><td>3S</td><?php TableCells_Temp("COT","6","2");?><?php TableCells2("2");?></tr>
<tr><td>4P</td><?php TableCells_Temp("COT","7","2");?><?php TableCells2("2");?></tr>
<tr><td>4S</td><?php TableCells_Temp("COT","8","2");?><?php TableCells2("2");?></tr>
<tr><td>5P</td><?php TableCells_Temp("COT","9","2");?><?php TableCells2("2");?></tr>
<tr><td>5S</td><?php TableCells_Temp("COT","10","2");?><?php TableCells2("2");?></tr>
<tr><td>P/L</td><?php TableCells_Temp("COT","11","2");?><?php TableCells2("2");?></tr>
<tr><td>OBQ</td><?php TableCells_Temp("COT","12","2");?><?php TableCells2("2");?></tr>
<tr>
<td></td>
<td><label>temp taken by</label><input type="decimal" name="r_132" value="" maxlength="10" size="5"/></td>
<td><label>temp taken by</label><input type="decimal" name="r_133" value="" maxlength="10" size="5"/></td>
<td>0</td>
<td>0</td>
</tr>
</table>
the functions i've used:
<?php function TableCells2($nColumn){
for($i=0;$i<$nColumn;$i++){?>
<td><input type="text" value="1" onchange="Formula_COT(this)" size="10%"></td>
<?php }}?>
i used TableCells2 to create the input boxes for the computation where i need to get the sum their sum vertically and subtract the OBQ from their total.
<?php function TableCells_Temp($TableName,$rowNum,$nColumn){
for($i=0;$i<$nColumn;$i++){?>
<td><input type="decimal" name="<?php echo $TableName.$rowNum."_1"; ?>" value="" maxlength="10" size="10"/></td>
<?php }}?>
this 2nd function is for inputs only, it doesn't need any computation
and finally this if for traversing the table and computation
var TableID = getTableID(tableID);
function getTableID(tableID){
while (tableID.nodeName.toLowerCase() != 'table')
tableID = tableID.parentNode;
TableID = tableID.id;
}
function getColumnCount() {
return document.getElementById(TableID).getElementsByTagName('tr')[0].getElementsByTagName('td').length;
}
function getRowCount() {
return document.getElementById(TableID).rows.length;
}
function Formula_COT(ths) {
var lastCol = getColumnCount()-1;
var lastRow = getRowCount()-1;
var table = document.getElementById(TableID);
var rowSum; /*Summation of all the values in of rows*/
var columnValue;
if(ths == 'on'){
for(var b=0;b<lastRow;b++){
rowSum = 0;
for(var i=0;i<lastCol-1;i++){
columnValue = table.rows[i].cells[b].childNodes[0].value;
if(columnValue != '' && !isNaN(columnValue)){
rowSum = eval(rowSum) + parseInt(columnValue);
}
table.rows[lastRow].cells[b].innerHTML = rowSum;
}
}
}else{
var cIndex = ths.parentNode.cellIndex;
rowSum = 0;
for(var i=0;i<lastRow;i++) {
columnValue = table.rows[i].cells[cIndex].childNodes[0].value;
if(columnValue != '' && !isNaN(columnValue)){
rowSum = eval(rowSum) + parseInt(columnValue);
}
}
table.rows[lastRow].cells[cIndex].innerHTML = rowSum;
}
}
the program doesn't compute anything ..
i know this seems to be boring bec of the long code but i urgently need help in this.
your help is very much appreciated . thanks in advance