Converting a string to an int
Hi, I'm working with a form that allows users to enter quantities. Into a table. on the next form, if I use <dtml-var "_[Category + '_qty']"> I get the value from the previous form exactly as I had planned--sortof. I then proceeded to do some calculations based on this variable and was told that I couldn't because it was a string. No problem thought I, I'll convert it to an integer and I used the following code to do so. <dtml-call "REQUEST.set('qty', _.string.atoi(_[Category + '_qty']))"> However, when I access the form, I get a Zope error that says: Error type: ValueError Error value: invalid literal for atoi() So, while it displays correctly, it does not appear to be a string, or an int: what is it? I have wondered if there was some weird translation error working with the _[Category...] stuff, so I assigned the result of _[Category...] to another variable and tried operating on it with the same result. Any clues would be appreciated. -- Stand Fast, tjg. Red Hat Certified Engineer tjg@avalongroup.net Chief Technology Officer www.avalongroup.net Avalon Technology Group, Inc. (503) 246-3630
>>>>>>Exceptional Minds, Innovative Products<<<<<<<<<<<<
Timothy Grant wrote:
Hi,
I'm working with a form that allows users to enter quantities. Into a table.
on the next form, if I use <dtml-var "_[Category + '_qty']"> I get the value from the previous form exactly as I had planned--sortof. I then proceeded to do some calculations based on this variable and was told that I couldn't because it was a string. No problem thought I, I'll convert it to an integer and I used the following code to do so.
<dtml-call "REQUEST.set('qty', _.string.atoi(_[Category + '_qty']))">
This is way too much effort. ;) Just name the form element: <input type=whatever name="Category:int"...> and ZPublisher will turn it into an int for you. -Michel
participants (2)
-
Michel Pelletier -
Timothy Grant