RE: [Zope] dtml-if and checkboxes
Well, I got one better:
<dtml-if check_box> The check box is checked! </dtml-if>
This works because if it's checked, then it's there. If it isn't checked, it isn't there, and it fails. So no output. Thanks for pushing me in the right direction. Russell -----Original Message----- From: Meilicke, Scott [mailto:scott.meilicke@intp.com] Sent: Friday, October 04, 2002 4:30 PM To: Hires, Russell (CAP, CARD); 'zope@zope.org' Subject: RE: [Zope] dtml-if and checkboxes <dtml-if check_box> <dtml-if expr="check_box == ('on')"> The check box is checked! </dtml-if> </dtml-if> The above should work, but there may be a better way... Maybe something like <dtml-if "check_box and check_box == ('on')">, not sure though. Scott -----Original Message----- From: Hires, Russell (CAP, CARD) [mailto:Russell.Hires@gecapital.com] Sent: Friday, October 04, 2002 1:15 PM To: 'zope@zope.org' Subject: [Zope] dtml-if and checkboxes Hey All, I'm experimenting with zope again, playing with the REQUEST object and form objects. In my latest delimma, I've got the following snippet: <dtml-if expr="check_box == ('on')"> The check box is checked! </dtml-if> What I don't get: if the checkbox is checked in the form, then this works, and I get the output. If it isn't checked, then I get an error saying that the checkbox ("check_box" in the form) isn't defined. This is borne out as well by <dtml-var expr="REQUEST.form">, which shows a text box's name and the value that it holds (whether it holds a value or not), and the checkbox's name and value ('on'), when it's checked. If it isn't checked, it isn't there at all. So, I guess I'm going to have to look to see whether it's there or not, right? How would I do that? Thanks for the help! Russell _______________________________________________ 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 ) The information contained in this email message may be privileged and is confidential information intended only for the use of the recipient or any employee or agent responsible for delivering it to the intended recipient. Any unauthorized use, distribution or copying of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately and destroy the original message and all attachments from your electronic files.
On Fri, Oct 04, 2002 at 04:51:14PM -0400, Hires, Russell (CAP, CARD) wrote: I emailled Rusell in a private email, but it may do some good to put it on the mailing list where others who have not travelled far in the way can see this:
Well, I got one better: <dtml-if check_box> The check box is checked! </dtml-if>
Be very careful with this form. If at some later date, you are working and change it to this: <dtml-if "check_box"> The check box is checked! </dtml-if> then your program will stop working again. Moreover, since the "simple form" above will try acquisition if check_box is not found in the REQUEST, you may have a very hard time debugging boxes that are unexepectedly checked. That is why the more explicit <dtml-if "REQUEST.has_key('check_box')"> The check box is checked! </dtml-if> is much preferable, even though it is a bit more typing. Same with zpt forms given. They are, by design, explicit. Jim Penny
This works because if it's checked, then it's there. If it isn't checked, it isn't there, and it fails. So no output.
Thanks for pushing me in the right direction.
Russell
participants (2)
-
Hires, Russell (CAP, CARD) -
Jim Penny