Passing the value of a checkbox from a form to a dtml-method
Hello, I have a problem doing <subject> I have added a checkbox in a form, but when the submit button is hitted, the value of the checkbox isn't passed along to the receiving method. The checkbox code looks like this: <INPUT TYPE="checkbox" NAME="isPublic"> Pretty normal I would say .. but perhaps someone out there have had my problem ? Regards, -- ************************ Gitte Wange Jensen System Squid Developer MMManager Aps +45 29 72 79 72 gitte@mmmanager.org ************************
Gitte Wange wrote:
Hello,
I have a problem doing <subject> I have added a checkbox in a form, but when the submit button is hitted, the value of the checkbox isn't passed along to the receiving method. The checkbox code looks like this: <INPUT TYPE="checkbox" NAME="isPublic">
Pretty normal I would say .. but perhaps someone out there have had my problem ?
I don't know exactly what problem you're having, but my guess is this will solve it. With checkboxes, the variable name does not exist in the REQUEST space unless the box is checked. So: <dtml-if isPublic> ...do some stuff... <dtml-else> ...do other stuff... </dtml-if> Put this little method in your root folder and use it as an action in your forms to help troubleshoot these issues (and other REQUEST problems). --- show_request DTML Method------- <dtml-var standard_html_header> <dtml-var REQUEST> <dtml-var standard_html_footer> ---------------------------------- HTH, -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (731) 884-4126 ONLINE DEMO: http://www.freepm.org:8080/FreePM
Gitte Wange wrote:
Hello,
I have a problem doing <subject> I have added a checkbox in a form, but when the submit button is hitted, the value of the checkbox isn't passed along to the receiving method. The checkbox code looks like this: <INPUT TYPE="checkbox" NAME="isPublic">
Pretty normal I would say .. but perhaps someone out there have had my problem ?
Regards,
You could try this: <input type="hidden" name="isPublic:default" value="0"> <input type="checkbox" name="isPublic" value="1"> If the checkbox is not checked, Zope will pass the default value in the hidden field instead. hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
[Casey Duncan]
You could try this:
<input type="hidden" name="isPublic:default" value="0"> <input type="checkbox" name="isPublic" value="1">
If the checkbox is not checked, Zope will pass the default value in the hidden field instead.
But if it IS checked, I believe the form will contain a list of the two values, that is, isPublic=["0","1"] At least, it works like that if you have several check boxes of the same name. So one way or another, somewhere you have to check the nature of the returned data. Cheers, Tom P
Hi Thomas, --On Dienstag, 1. Mai 2001 11:34 -0400 "Thomas B. Passin" <tpassin@mitretek.org> wrote:
[Casey Duncan]
You could try this:
<input type="hidden" name="isPublic:default" value="0"> <input type="checkbox" name="isPublic" value="1">
If the checkbox is not checked, Zope will pass the default value in the hidden field instead.
But if it IS checked, I believe the form will contain a list of the two values, that is,
isPublic=["0","1"]
At least, it works like that if you have several check boxes of the same name. So one way or another, somewhere you have to check the nature of the returned data.
There is a difference, its the ":default" modifier. with it it works as described - if no value is retuerned, zope uses this value instead. Regards Tino
[Gitte Wange] I have a problem doing <subject> I have added a checkbox in a form, but when the submit button is hitted, the value of the checkbox isn't passed along to the receiving method. The checkbox code looks like this: <INPUT TYPE="checkbox" NAME="isPublic"> You have to supply a "value" attribute. For example, if you have <INPUT TYPE="checkbox" NAME="isPublic" value='on'> Then, when the box has been checked, the form will contain 'on' as the value of 'isPublic'. If the box is not checked, that property will not exist in the form's returned data. Cheers, Tom P
participants (5)
-
Casey Duncan -
Gitte Wange -
Thomas B. Passin -
Tim Cook -
Tino Wildenhain