RE: [Zope] Checkbox form data storage was (Help with expr)
Hi Todd, Please keep this thread on the mailing list...
I have one column named membership type varchar(30) OK. I'm assuming that the field has values like: "D,A,M,I,T" (heehee, couldn't resist :)
If so, you will need to convert the list of strings in the "membership" REQUEST variable to a string of comma separated values before you update your database with a ZSQL Method. Hint: read about Python's string.join() function (accessible in DTML with <dtml-var expr="_.string.join()">) Eric.
Hi Todd, Does your database table have *one* string field named "membership" or are there many boolean fields that represent the different memberships that each user record can have? Depending on that answer, you will need to use a different method to store the checkbox data in your database.
When your form is submitted, Zope will interpret your check boxes as a list of string values. You can verify this by posting your form to a DTML method that includes: <dtml-var REQUEST> and looking at the form variables. That list represents the items checked in your form.
In your ZSQL Method you can use the <dtml-sqlgroup> , <dtml-sqlvar> and <dtml-sqltest> tags to dynamically build your SQL string.
Have a look at the "Passing Parameters to Scripts" and "Dynamic SQL Queries" sections of the Zope Book. There are a lot of great examples there.
-----Original Message----- From: Todd Loomis [mailto:tloomis@dmso.mil] Sent: Friday, August 10, 2001 8:45 AM To: eric@walstads.net Subject: RE: [Zope] Help with expr Eric: I have a set of check boxes that can be checked if the person is a member. My problem is if I pick more than one membership nothing goes into the database. So when bring the record up to view or edit I get no boxes checked even if they should be, here's my codes: Form: <input type="checkbox" name="membership" value="D"> DMSO <input type="checkbox" name="membership" value="A"> AMG <input type="checkbox" name="membership" value="E"> EXCIMS <input type="checkbox" name="membership" value="M"> MSWG <br> <input type="checkbox" name="membership" value="V"> VV&A TWG <input type="checkbox" name="membership" value="T"> VV&A TST <input type="checkbox" name="membership" value="I"> MSTWG
SQL: <dtml-var membership type="string">
Todd
Oh, I just noticed that Tino W. posted a better solution to Charlene. You might want to have a look at that one. -E
-----Original Message----- From: Eric Walstad [mailto:eric@walstads.net] Sent: Friday, August 10, 2001 10:36 AM To: zope@zope.org; Todd Loomis Subject: RE: [Zope] Checkbox form data storage was (Help with expr)
Hi Todd, Please keep this thread on the mailing list...
I have one column named membership type varchar(30) OK. I'm assuming that the field has values like: "D,A,M,I,T" (heehee, couldn't resist :)
If so, you will need to convert the list of strings in the "membership" REQUEST variable to a string of comma separated values before you update your database with a ZSQL Method.
Hint: read about Python's string.join() function (accessible in DTML with <dtml-var expr="_.string.join()">)
Eric.
Where should I put this. I put in my SOL method and get problems: <dtml-in yourlist> <dtml-unless sequence-start>,</dtml-unless> <dtml-sqlvar sequence-item type=int> </dtml-in> If i select 2 checkboxes one goes into the database correct the other gets added to the next field. Todd At 10:40 AM 8/10/2001 -0700, you wrote:
Oh, I just noticed that Tino W. posted a better solution to Charlene. You might want to have a look at that one. -E
-----Original Message----- From: Eric Walstad [mailto:eric@walstads.net] Sent: Friday, August 10, 2001 10:36 AM To: zope@zope.org; Todd Loomis Subject: RE: [Zope] Checkbox form data storage was (Help with expr)
Hi Todd, Please keep this thread on the mailing list...
I have one column named membership type varchar(30) OK. I'm assuming that the field has values like: "D,A,M,I,T" (heehee, couldn't resist :)
If so, you will need to convert the list of strings in the "membership" REQUEST variable to a string of comma separated values before you update your database with a ZSQL Method.
Hint: read about Python's string.join() function (accessible in DTML with <dtml-var expr="_.string.join()">)
Eric.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Todd Loomis Web Developer (SAIC) Defense Modeling & Simulation Office 1901 N. Beauregard Street, Suite 500 Alexandria, VA 22311 Office: 703.824.3407 Fax: 703.379.3778 tloomis@dmso.mil
Hi Todd, I'm under a project deadline crunch here and don't have the time right now to help more, sorry. To get you up and running, try using something like: INSERT INTO (your_string_field) VALUES ("<dtml-var expr="_.string.join(your_check_box_list, ',')">"); **DISCLAIMER** This is a hack (probably unsafe, use with caution), but it might help you get rolling. Good Luck, Eric.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Todd Loomis Sent: Friday, August 10, 2001 11:11 AM To: zope@zope.org Subject: RE: [Zope] Checkbox form data storage was (Help with expr)
Where should I put this. I put in my SOL method and get problems:
<dtml-in yourlist> <dtml-unless sequence-start>,</dtml-unless> <dtml-sqlvar sequence-item type=int> </dtml-in>
If i select 2 checkboxes one goes into the database correct the other gets added to the next field.
Todd
At 10:40 AM 8/10/2001 -0700, you wrote:
Oh, I just noticed that Tino W. posted a better solution to Charlene. You might want to have a look at that one. -E
-----Original Message----- From: Eric Walstad [mailto:eric@walstads.net] Sent: Friday, August 10, 2001 10:36 AM To: zope@zope.org; Todd Loomis Subject: RE: [Zope] Checkbox form data storage was (Help with expr)
Hi Todd, Please keep this thread on the mailing list...
I have one column named membership type varchar(30) OK. I'm assuming that the field has values like: "D,A,M,I,T" (heehee, couldn't resist :)
If so, you will need to convert the list of strings in the "membership" REQUEST variable to a string of comma separated values before you update your database with a ZSQL Method.
Hint: read about Python's string.join() function (accessible in DTML with <dtml-var expr="_.string.join()">)
Eric.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Todd Loomis Web Developer (SAIC) Defense Modeling & Simulation Office 1901 N. Beauregard Street, Suite 500 Alexandria, VA 22311 Office: 703.824.3407 Fax: 703.379.3778 tloomis@dmso.mil
_______________________________________________ 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 (2)
-
Eric Walstad -
Todd Loomis