[Zope] selected in select lists
Garry Saddington
garry at schoolteachers.co.uk
Wed Oct 12 18:16:07 EDT 2005
J Cameron Cooper wrote:
> Garry Saddington wrote:
>
>> Nicolas Gouzy wrote:
>>
>>> I think this code works :
>>>
>>> <select name="groupabbrev">
>>> <dtml-in getpastoralgroups>
>>> <option value="<dtml-var expr="_['sequence-item']">" <dtml-if
>>> expr="groupabbrev==_['sequence-item']"> selected</dtml-if> ><dtml-var
>>> expr="_['sequence-item']"></option>
>>> </dtml-in>
>>> </select>
>>>
>>> --
>>> Nicolas Gouzy
>>> nicolas.gouzy at gmail.com
>>>
>>>
>>>
>>>
>> This producing the following result, is this what it should do?
>> <select name="groupabbrev">
>> <option value="<Shared.DC.ZRDB.Results.r object at
>> 0x43aa7c0c>"><Shared.DC.ZRDB.Results.r object at 0x43aa7c0c></option>
>> <option value="<Shared.DC.ZRDB.Results.r object at
>> 0x43f95824>"><Shared.DC.ZRDB.Results.r object at 0x43f95824></option>
>> <option value="<Shared.DC.ZRDB.Results.r object at
>> 0x43aa7c0c>"><Shared.DC.ZRDB.Results.r object at 0x43aa7c0c></option>
>> <option value="<Shared.DC.ZRDB.Results.r object at
>> 0x43f95824>"><Shared.DC.ZRDB.Results.r object at 0x43f95824></option>
>> </select>
>
>
> Like I said: be careful about what comes out of getpastoralgroups.
>
> These are Result objects, not strings. Like any result objects, they
> store data in attributes with the same name as the row that came out
> of the SQL results.
>
> You must use a row in your comparison: a Result object can never be
> equal to a string.
>
> --jcc
I have solved this with the following, I hope it may be of help to others:
ZSQL:
select groupabbrev as thisgroupabbrev from pastoralgroup
DTML:
<select name="groupabbrev">
<dtml-in getpastoralgroups>
<option value="<dtml-var thisgroupabbrev>" <dtml-if
expr="groupabbrev==_.str(thisgroupabbrev)"> selected</dtml-if>
><dtml-var thisgroupabbrev></option>
</dtml-in>
</select>
Thanks for all your help
Garry
More information about the Zope
mailing list