Trying to get Form/Checkbox value into Python Script
I've found the problem with getting data into a python script. It is with the checkboxes. If the checkbox is checked, the parameter is passed and the boolean property is set properly. However, if the checkbox is unchecked, I get a Zope error indicating that the parameter was NOT passed. Same form, same everything except in the test second test case the checkbox was unchecked. In essense, it only passes the checkbox value when the checkbox is checked. Does anyone know what I'm doing wrong? How do you pass boolean values (i.e., from checkboxes) to a python script when the box is unchecked? Thanks, Ron
ron, in a python script you can assign a "default" value in the parameter list, just like in the argument list to a pythoin function itself. i would set this checkbox parameter value to a default of maybe None in the parameter list and in the script itself simply assume that if the value is indeed None the checkbox has not been selected. jens On Saturday, September 29, 2001, at 08:09 , Ronald L. Chichester wrote:
I've found the problem with getting data into a python script. It is with the checkboxes.
If the checkbox is checked, the parameter is passed and the boolean property is set properly.
However, if the checkbox is unchecked, I get a Zope error indicating that the parameter was NOT passed. Same form, same everything except in the test second test case the checkbox was unchecked. In essense, it only passes the checkbox value when the checkbox is checked. Does anyone know what I'm doing wrong? How do you pass boolean values (i.e., from checkboxes) to a python script when the box is unchecked?
Thanks,
Ron
Ronald, You're not doing anything wrong. That's how HTML Forms work. They only pass the value of a checkbox back to the server if it is selected, omission means false. you can get the correct value with something like: cbvalue=context.REQUEST.get('cb','defaultValue') hth Phil On 29 Sep 2001 07:09:19 -0500, Ronald L. Chichester wrote:
I've found the problem with getting data into a python script. It is with the checkboxes.
If the checkbox is checked, the parameter is passed and the boolean property is set properly.
However, if the checkbox is unchecked, I get a Zope error indicating that the parameter was NOT passed. Same form, same everything except in the test second test case the checkbox was unchecked. In essense, it only passes the checkbox value when the checkbox is checked. Does anyone know what I'm doing wrong? How do you pass boolean values (i.e., from checkboxes) to a python script when the box is unchecked?
Thanks,
Ron
_______________________________________________ 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 )
participants (3)
-
Jens Vagelpohl -
Phil Harris -
Ronald L. Chichester