I have a function that sums the values of a column of data that works fine if I change the values of one of the columns. That same function is being called when the page loads but no values are returned so that the sum is zero. I am using Google Chrome so that I can write to the console and I see that the input fields that I am wanting to sum are being captured. When I drill down on each input field I can also see that the value of each field is present. Why is that value not being returned on page load? Below is the function;
function
sumOfActualColumns(tableID, columnIndex, hasHeader) {
var
actualTot = 0;
$(
"#"
+ tableID +
" tr"
+ (hasHeader ?
":gt(0)"
:
""
))
.children(
"td:nth-child("
+ columnIndex +
")"
)
.each(
function
() {
thisActualVal = $(
this
).children(
'input[id*="ActualsTotal"]'
).val().replace(/[^\d\.\-\ ]/g,
''
);
thisActualVal = Number(thisActualVal);
if
(!isNaN(thisActualVal))
actualTot += thisActualVal;
});
return
actualTot;
}