column total from a loop...
The large 542.81 is meant to be a total of the column of amounts. As you can see it is displaying the last piece of information in the column rather than the total.
The code i am using is listed below. What have i done wrong? What must i change to make this work?
thanks

- htmlpage Date__Form1(From, To)
displayname = "Expense Pie Chart"
print = true
content
<%{%>
<div elName='zc-component' formLinkName='Pie_Chart_To_From_Date' params='zcSuccMsg=Thank You'>Loading Form</div> <br><¬tualExpense = map();
if ((((input.From != null) && (input.To != null)) || (input.From != null)) || (input.To != null))
{
cat = add_new_expense1 [ID != 0];%>
<p> </p>
<table zc-viewtable width="100%" cellspacing="1" cellpadding="1" border="0">
<tbody>
<tr class="zc-row-header">
<td colspan="3" class="zc-viewtitle">Pie Chart Report From <%=From.toDate()%> To <%=To.toDate()%></td>
</tr>
<tr class="zc-row-header">
<td class="zc-viewrowheader">Date</td>
<td class="zc-viewrowheader">Category</td>
<td class="zc-viewrowheader">Sub Category</td>
<td class="zc-viewrowheader">Description</td>
<td class="zc-viewrowheader">Agent Name</td>
<td class="zc-viewrowheader">Payment Method</td>
<td class="zc-viewrowheader">Cheque #</td>
<td class="zc-viewrowheader">Amount</td>
<td class="zc-viewrowheader">Additional Information</td>
</tr>
<%for each r in cat
{
tot = 0.0;
totact = 0.0;
totact2 = 0.0;
act = add_new_expense1 [((Category == r.Category && Expense_Date >= input.From.toDate()) && Expense_Date <= input.To.toDate())];
if (count(add_new_expense1[((Category == r.Category && Expense_Date >= input.From.toDate()) && Expense_Date <= input.To.toDate())]) != 0)
{
for each r1 in act
{
totact = (totact + r1.Amount);
}
actualExpense.put(r.Category, totact + "");%>
<tr class=zc-viewrow>
<td><%=r.Expense_Date%></td>
<td><%=r.Category%></td>
<td><%=r.Sub_category%></td>
<td><%=r.Description%></td>
<td><%=r.Agent_name1%></td>
<td><%=r.Payment_method%></td>
<td><%=r.Cheque%></td>
<td><%=r.Amount%></td>
<td><%=r.Additional_Information%></td>
</tr>
<%}%>
<tr class=zc-viewrow>
</tr> <%}%>
<td colspan="8" style="text-align: right;"/><%=totact%></td>
</tbody>
</table>
<img src="<%=thisapp.getChartUrl("PIE","Expense Pie Chart","Category","Actual Expense",actualExpense,"500","500")%>"/>
<%}
}%>