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  <input type=radio name=responsiveness value=2>2  <input type=radio name=responsiveness value=3>3  <input type=radio name=responsiveness value=4>4  <input type=radio name=responsiveness value=5>5  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
Hello, Michael. The problem here, is not the NULL value of the variable responsiveness. The problem is that the variable responsiveness does not exit in the namespace you are passing to the ZSQLMethod. I think you have three parts to process the Form: ----- Original Message ----- From: "Montagne, Michael" <montagne@BOORA.com> To: <zope@zope.org> Sent: Friday, September 14, 2001 2:36 AM Subject: [Zope] Null value from Form Input
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:
1. The Insert ZSQLMethod: (sqlInsert may be the name)
INSERT INTO tblContactEval (responsiveness) VALUES(<dtml-sqlvar responsiveness type="int" optional>);
2. The Form in a dtml document or method with <form action="insert"...
The form looks something like this: <input type=radio name=responsiveness value=1>1  <input type=radio name=responsiveness value=2>2  <input type=radio name=responsiveness value=3>3  <input type=radio name=responsiveness value=4>4  <input type=radio name=responsiveness value=5>5 
3. You have the insert method wich must look like this: <dtml-call "sqlInsert()"> I think the error is here. May be you are doing <dtml-call sqlInsert> so the actual REQUEST namespace isn´t passed to the ZSQLMethod. I hope I have helped you. Antonio Carrasco What is the best way of do CVS in a Zope project? This my question. Have you make a project in Zope, how do you do it? This is my question. Thank you to all no one who has answered me. Pleasssssseeeeeee!. It´s easy. Give me some ideas!!!!. I need an advice!!!
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 )
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  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  <input type=radio name=responsiveness value=2>2  <input type=radio name=responsiveness value=3>3  <input type=radio name=responsiveness value=4>4  <input type=radio name=responsiveness value=5>5 
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
participants (3)
-
Antonio Carrasco -
Michael Montagne -
Montagne, Michael