[Zope] dtml-in totals

Chris Humphries chumphries@devis.com
Thu, 14 Feb 2002 15:18:04 +0000


you can do it in sql, if what you are doing irl is the example.

in dtml:
   <dtml-in sql_statement prefix="seq">
   [hopefully dollar amount is just a number]
   <dtml-call "REQUEST.set('total', total + seq_item['dollar_amount'])">
   </dtml-in>

though a python script would be better to do this in:
   total=0
   resultset=content.sql_method()
   if len(resultset) > 0:
      for result in resultset:
          total += int(result.dollar_amount)
   return total


D. Rick Anderson wrote:

> I need to total variable from a dtml-in and give the result at the bottom. 
> I can't seem to figure out what needs to be done to get this result. If I 
> have the following:
> 
> <dtml-in sql_statement>
> <table>
>  <tr>
>   <td>
>    <dtml-var dollar_amount>
>   </td>
>  </tr>
> </table>
> </dtml-in>
> 
> How do I total all the iterations of dollar_amount? Is there a way in dtml 
> to put a variable in that stores a running total?
> 
> TIA
> 
> Rick
> 
> 
> 
> 


-- 
Chris Humphries
Systems Analyst
DevIS
540.537.3904