Expression Evaluation Problem (Newbee Question)
Hi, I'm not realy new into Zope but suddenly found a strange question. I'm not shure where the problem is: - on a form a user can choose a checkbox and the value is stored into xtype - in the next document I can access the value of xtype with <dtml-var xtype> the correct value is printed out. - but if I do a check like <dtml-if "xtype ==1"> I get no matching. What am I doing wrong? Thanks Borno -- Sent through Global Message Exchange - http://www.gmx.net
- but if I do a check like <dtml-if "xtype ==1"> I get no matching. You did not declare xtype to be an integer. You can do that with <dtml-if "_.int(xtype) == 1">. But you can also declare the variable from the very beginning as integer, so you don't have to cast it in the if statement: <input type=checkbox name=xtype:int value=1>
Have fun und einen schoenen Sonntag noch, Stephan -- Stephan Richter iXL - Software Designer and Engineer CBU - Physics, Computer Science and Chemistry Student
Assuming you have <input type="checkbox" value="1" name="xtype">, then your if statement needs to be <dtml-if "xtype=='1'"> (note the extra single quotes), which does a string comparison. Otherwise, you are comparing the ascii code of '1' with the ascii code, 1. They don't match. Alternatively, you could put <input type=checkbox value="1" name="xtype:int">, which will force the form field to be cast into an int. Or else you could have <dtml-if "_.int(xtype)==1">, which explicitly does the cast for you. --sam Borno Janekovic wrote:
Hi,
I'm not realy new into Zope but suddenly found a strange question. I'm not
shure where the problem is:
- on a form a user can choose a checkbox and the value is stored into xtype - in the next document I can access the value of xtype with <dtml-var xtype> the correct value is printed out. - but if I do a check like <dtml-if "xtype ==1"> I get no matching.
What am I doing wrong?
Thanks
Borno
-- Sent through Global Message Exchange - http://www.gmx.net
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Sam Gendler Chief Technology Officer - Impossible, Inc. 1222 State St. Suite 250 Santa Barbara CA. 93101 w: 805-560-0508 f: 805-560-0608 c: 805-689-1191 e: sgendler@impossible.com
participants (3)
-
Borno Janekovic -
Sam Gendler -
Stephan Richter