[Zope] HTML forms: how to get the value of an unchecked
checkbox?
Tino Wildenhain
tino@wildenhain.de
Mon, 07 May 2001 16:08:47 +0200
Hi Stephane,
one solution is to let zope handle this. Include
the following into your form:
<input type="hidden" name="sugar:default" value="no">
<input type="hidden" name="milk:default" value="no">
HTH
Tino Wildenhain
--On Montag, 7. Mai 2001 15:48 +0200 Stephane Bortzmeyer
<bortzmeyer@netaktiv.com> wrote:
> I made many HTML forms with Zope but now, I need checkboxes. If I try:
>
> <FORM action="handleForm">
> <INPUT TYPE="checkbox" NAME="sugar" CHECKED>Sugar?
> <INPUT TYPE="checkbox" NAME="milk">Milk?<BR>
> <INPUT TYPE="submit" NAME="submit" VALUE="Order">
> </FORM>
>
> The Python Script handleForm cannot run if Milk is unchecked. This is
> because HTML browsers only send the value of the checkbox if it is
> checked. The URL sent looks like:
>
> http://progress.netaktiv.com:9673/Tests/handleForm?sugar=on&submit=Order
>
> (do note there is no Milk)
>
> and the error message is:
>
> ---------
> Site Error
>
> An error was encountered while publishing this resource.
>
> Invalid request The parameter, milk, was omitted from the request.
>
> Make sure to specify all required parameters, and try the request
> again.
> ---------
>
> Of course, milk is in the parameters of the Python Script, but how can
> I say that it is optional and should default to false? Using
> "milk:boolean" as its name changes nothing.
>
>
>
> Zope 2.3.2 (source release, python 1.5.2, linux2)
>
>
>
> _______________________________________________
> 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 )