[Zope] Null value from Form Input

Michael Montagne Michael Montagne <montagne@boora.com>
Fri, 14 Sep 2001 12:00:37 -0700


Here is the solution that ended up working for me.  
INSERT INTO tblContactEval (responsiveness)
VALUES(<dtml-sqlvar responsiveness type=nb optional>);
Using type=nb and optional together causes empty strings to be passed as NULL

 <input type=radio name=responsiveness value=''>NA&nbsp
 For those entries that don't apply, pass the empty string.

 Now I can get accurate averages very easily because the SQL avg function wil filter out NULL rows for me.

On Thu, Sep 13, 2001 at 05:36:17PM -0700, Montagne, Michael wrote:
> I have a form with a series of radio buttons that allow rating 1-5.  In
> order to make it easier to get an average of those numbers, I'd like to
> allow NULL inputs.  A snippet of my SQL method to update the database is:
> INSERT INTO tblContactEval (responsiveness)
> VALUES(<dtml-sqlvar responsiveness type="int" optional>);
> 
> The form looks something like this:
> <input type=radio name=responsiveness value=1>1&nbsp
> <input type=radio name=responsiveness value=2>2&nbsp
> <input type=radio name=responsiveness value=3>3&nbsp
> <input type=radio name=responsiveness value=4>4&nbsp
> <input type=radio name=responsiveness value=5>5&nbsp
> 
> When I do not check any radio button in that group I get a "Bad Request"
> error citng the "responsiveness" variable.  How can I get a NULL value into
> my database for those situations where this category does not apply?
> 
> thanks,
> mjm
> 
> 
> 
> _______________________________________________
> 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 )

-- 
Michael Montagne
montagne@boora.com
http://www.boora.com