Forums

ASP

This topic is locked

Calculating fields

Posted 29 Mar 2002 04:03:39
1
has voted
29 Mar 2002 04:03:39 Ryan Miller posted:
I have a site on Page 1 there is a series of dynamic menu boxes that the used selects from, then submits to a confirmation page ...

On the confirmation page the I have a table with Show Region behaviour if RS not empty.. all works fine .. Each of the 'Regions' has a qty, cost and total field... ie Qty1, Cost1, Total1. Depending on the selections on previous page 1 or up to 30 of these regions will show.

I having trouble getting script to calculate the total fields based on qty and cost .... can anybody help ..

Cheers, Ryan

Replies

Replied 29 Mar 2002 07:13:20
29 Mar 2002 07:13:20 Owen Eastwick replied:
Within the repeat region set up a variable to add the totals, something like:

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<% TotalCost = 0 %>
<%
While ((Repeat1__numRows <> 0) AND (NOT RecordsetName.EOF))
%>
<tr>
<td><%= ItemName %></td>
<td><%= ItemCost %></td>
<td><%= ItemQuantity %></td>
<td><% ItemTotal = ItemCost * ItemTotal %><%= ItemTotal %></td>

</tr>
<% TotalCost = TotalCost + ItemTotal %>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
RecordsetName.MoveNext()
Wend
%>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><%= TotalCost %></td>
</tr>
</table>

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo

Reply to this topic