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
On Fri, Oct 04, 2002 at 04:15:01PM -0400, Hires, Russell (CAP, CARD) wrote:
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?
This is how HTML works. Rather bad design. You want something like: <dtml-if expr="REQUEST.has_key('check_box') and check_box == 'on'"> Checked! </dtml-if> Note that the second part is completely redundant. <dtml-if expr="REQUEST.has_key('check_box')"> Checked! </dtml-if> Does the same thing. In ZPT, this looks like <span tal:condition="python:request.has_key('check_box')">Checked!</span> Or, more probably <input type="checkbox" name="check_box" tal:attributes="checked request/check_box|nothing" /> Jim Penny
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 )
I have found similar statements a few times around, that is some empty form fields are not trasmitted with the client request. However, I couldn't manage to find in the W3C HTML specifications where exactley this point is exposed: has somebody a precise link? Or is a matter of specification implementaion (and then browser dependent)? TIA, p.t. At 16:34 04/10/2002 -0400, Jim Penny wrote:
This is how HTML works. Rather bad design. <SNIP>
Jim Penny
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 )
_______________________________________________ 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 )
On Sat, Oct 05, 2002 at 12:09:37AM +0200, p.t. wrote:
I have found similar statements a few times around, that is some empty form fields are not trasmitted with the client request. However, I couldn't manage to find in the W3C HTML specifications where exactley this point is exposed: has somebody a precise link? Or is a matter of specification implementaion (and then browser dependent)? TIA, p.t.
This is old: but here is one reference http://www.w3.org/MarkUp/HTMLPlus/htmlplus_42.html "The form contents are expressed as a property list of attribute names and values. Radio buttons and checkboxes are left out of the list when unchecked. This ensures that only the selected radio button contributes a name=value pair. Omitting the VALUE attribute for a checkbox field causes the field when checked to appear as a name without a value (this is appropriate for Boolean attributes)." Jim
At 16:34 04/10/2002 -0400, Jim Penny wrote:
This is how HTML works. Rather bad design. <SNIP>
Jim Penny
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 )
_______________________________________________ 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 )
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks, Jim. This is why you rock. Now I know something about HTML that I never would have found in any zope docs. Russell
This is old: but here is one reference http://www.w3.org/MarkUp/HTMLPlus/htmlplus_42.html
"The form contents are expressed as a property list of attribute names and values. Radio buttons and checkboxes are left out of the list when unchecked. This ensures that only the selected radio button contributes a name=value pair. Omitting the VALUE attribute for a checkbox field causes the field when checked to appear as a name without a value (this is appropriate for Boolean attributes)."
Jim
At 16:34 04/10/2002 -0400, Jim Penny wrote:
This is how HTML works. Rather bad design.
<SNIP>
Jim Penny
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 )
_______________________________________________ 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 )
_______________________________________________ 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 )
- -- Linux -- the OS for the Renaissance Man -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9nlEJAqKGrvVshJQRAj4hAJ9P2UqL9Rc/rTKrlaBeoxR26zWxeQCfdxtO Nps039iw7BZGFHQ5fChqw9Y= =jmEz -----END PGP SIGNATURE-----
Jim, thanks for the link. It helped me to better understand what it is written in: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13 which confirms that only some form controls are sent on submission and depending on their values. I know that this argument is out of topoic, but again I couldn't find any explicity reference to onother point concerning HTML forms, and that is: " is there any specification (or statement) about how the controls should be ordered when a user agent sends a submitted form? " Shoul the sent control's (name=value) be arranged in the order they are received? Or in the tabbing order (if and when specified)? Does somebody knows how to find "official" information on this point? Thanks and again sorry for this OT thread, p.t. At 06:51 PM 10/4/2002 -0400, Jim Penny wrote:
This is old: but here is one reference http://www.w3.org/MarkUp/HTMLPlus/htmlplus_42.html
"The form contents are expressed as a property list of attribute names and values. Radio buttons and checkboxes are left out of the list when unchecked. This ensures that only the selected radio button contributes a name=value pair. Omitting the VALUE attribute for a checkbox field causes the field when checked to appear as a name without a value (this is appropriate for Boolean attributes)."
participants (4)
-
Hires, Russell (CAP, CARD) -
Jim Penny -
p.t. -
Russell Hires