0 Replies Latest reply on Dec 2, 2008 8:09 PM by oaktown_matt

    computing sums and averages on datagrid columns

    oaktown_matt
      Hi there,

      Pretty n00by here, but getting stronger. Here's my problem:

      I have a datagrid (not advanced, the original datagrid) and I found some code online that shows how to loop through column values to compute a sum. First function calcTotalViews works, second function calcPercent does not.

      So, if I try to use Number instead of int - I get NaN as a result. But either way, the average that is computed is not correct, it basically takes the final result in the cursor and makes that the Average.

      Basically, if there is a better way of looping through the columns, not using a cursor, I would rather give that a shot. When I put an Alert box on the resultTotal as the cursor moves, the Alert shows that the number is changing, but the returned resultTotal is, inevitably, the final value in the cursor. Is this a problem with scope?

      Help?

      Thanks