[Zope] Re: Simple calculation

Maik Jablonski maik.jablonski@uni-bielefeld.de
Mon, 24 Feb 2003 18:29:01 +0100


Marc Burgauer wrote:
> I am obviously thick. ;-)
> 
> I want to do a simple calculation in a dtml tag and print the result:
> 
> <dtml-var expr="85 * HowOften">
> 
> HowOften is a value that has been set by an HTML input in a web form. When I
> run this with a value of 3 for the result is that it prints the character 3
> 85 times! So it treats it as a string.
> 
> Obviously I need to convert HowOften to a float, but how do I do it?

Two possible ways:

You can "marshall" the html-input-text with:

<input type="text" name="HowOften:float">

in your web-form or you can convert it in your result-page with:

<dtml-var "85 * _.float(HowOften)">

-mj

-- 
German Zope User Group (DZUG) - http://www.dzug.org/