All: 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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, as a service, Zope gives you a list if more then one value of the same name exist in a form. For what python types and especially lists are please see http://www.python.org/ -> Documentation -> Tutorial However, if you relie on this and get only one value, its not a list. However there are posibilities to cast an value explicitely to a list. If you change your form like this: <input type="checkbox" name="membership:list" value="D"> DMSO <input type="checkbox" name="membership:list" value="A"> AMG <input type="checkbox" name="membership:list" value="E"> EXCIMS <input type="checkbox" name="membership:list" value="M"> MSWG <br> <input type="checkbox" name="membership:list" value="V"> VV&A TWG <input type="checkbox" name="membership:list" value="T"> VV&A TST <input type="checkbox" name="membership:list" value="I"> MSTWG You get always a list, no matter if there is one or any checkbox checked. If there is no checkbox checked, you do not get anything at all! So you might have to look for it (or use a default). You should avoid using <dtml-var> in SQL Methods. Instead use <dtml-sqlvar> since this quoutes correctly. Also <dtml-var ... sql_quote> can be used. If you dont do so, you probably open a security hole. Regards Tino --On Freitag, 10. August 2001 11:53 -0400 Todd Loomis <tloomis@dmso.mil> wrote:
All:
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 )
Todd Loomis writes:
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="I"> MSTWG
SQL: <dtml-var membership type="string"> You should add a ":list" suffix to the form control name "membership". This will ensure that you will get a list, when the user checked at least one checkbox.
You still need to handle the case that the user did not check any box. You could use: <dtml-unless membership><dtml-call "REQUEST.set('membership',_.None)"></dtml-unless> If you keep your code, your membership entries will have the form: ['D', 'A', ... ] Not sure, whether you want that in the database? I would not expect this. Dieter
participants (3)
-
Dieter Maurer -
Tino Wildenhain -
Todd Loomis