I’m trying to get this to work and don’t know what is wrong with the code. This is a very simple script to add the total of 2 columns, here is the code:
Thanks in advanced,
Aaron
<html>
<head>
<script language=”javascript”>
var cellcounter = 0;
var colValues = new Array(2);
var colTotals = 0;
var avgCorrector = 0;
var colAvg = 0;
function averageValues() {
for (i=0;i<=cellcounter-1;i=i+1)
{
if (isNaN(colValues[i])==true II colValues[i] == “”) {
colValues[i] = 0;
avgCorrector = avgCorrector + 1;
}
else
{
colTotals = colTotals + parseFloat(colValues[i]);
}
}
colAvg = colTotals / (cellcounter – avgCorrector);
colAvg = Math.round(colAvg * 10)/10;
document.getElementById(“avg1”).innerHTML = colTotals;
}
</script>
</head>
<body onload=”averageValues();”>
<table width=”665″ border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td>Office #</td>
<td>
<script language=”javascript”>
document.write(“2”);
colValues[cellcounter]=”2″;
parseFloat(colValues[cellcounter]);
</script>
</td>
</tr>
<tr>
<td>Office ID</td>
<td>
<script language=”javascript”>
document.write(“7”);
colValues[cellcounter]=”7″;
parseFloat(colValues[cellcounter]);
</script>
</td>
</tr>
<tr>
<td>Total Amount: </td>
<td><span id=”avg1″> …Total should go here </span></td>
</tr>
</table>
</body>
</html>