[Zope] Checkbox Help
Tino Wildenhain
tino@wildenhain.de
Fri, 10 Aug 2001 19:13:34 +0200
Hi Todd,
--On Freitag, 10. August 2001 12:35 -0400 Todd Loomis <tloomis@dmso.mil> wrote:
> Tino:
>
> Thanks, but now I get in the database ['D', 'A'].
Its not ['D', 'A'] its a list with the strings 'D' and 'A' :-)
['D', 'A'] is only a view on the list object if it gets translated
to a string directly.
It depends on you what you actually want to do with the values.
You might probably want to make a SQL statement like this:
select ... where something in (value1,value2, ...)
A quite "clean" way would be:
select ... where something in (
<dtml-in valuelist><dtml-sqlvar sequence-item type=string><dtml-unless
sequence-end>,</dtml-unless>
</dtml-in> ) ...
HTH
Tino Wildenhain
PS: back to the list, since it seems to be an FAQ today.
>
> Todd
>
>
> At 06:25 PM 8/10/2001 +0200, you wrote:
>> 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
> 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
>
>