[Zope] selected in select lists

J Cameron Cooper zope-l at jcameroncooper.com
Wed Oct 12 17:31:26 EDT 2005


Garry Saddington wrote:
> J Cameron Cooper wrote:
> 
>> Garry Saddington wrote:
>>
>>>
>>> I have a variable called 'groupabbrev' in the REQUEST. I am trying to 
>>> automatically select an option in a select list based on this variable.
>>> I have tried this code and many others, and many googles but have not 
>>> found anything that works. Can anyone see what I am doing wrong?
>>>
>>>
>>> <select name="groupabbrev">
>>> <dtml-in getpastoralgroups>
>>> <option value="<dtml-var groupabbrev>" <dtml-if 
>>> expr="'groupabbrev'==_['sequence-item']"> selected</dtml-if> 
>>> ><dtml-var groupabbrev></option>
>>> </dtml-in>
>>> </select>
>>
>>
>>
>> Why have you put 'groupabbrev' in quotes? 
> 
> 
> I am fishing in the dark
> 
>> That makes it a string, and the condition will only be true when the 
>> current item is equal to "groupabbrev".
>>
>> Presumably you want the value of the variable named that, rather than 
>> a string of that name.
>>
>> Also, watch the values of what 'getpastoralgroups' returns. The 
>> condition will never be true if they are not strings or converted into 
>> such.
>>
>>         --jcc
> 
> 
> Now I have tried both of the following with no result:
> <dtml-if expr="groupabbrev==_.str(_['sequence-item'])">
> 
> <dtml-if expr="groupabbrev==_['sequence-item']">
> 
> Are there any other ways I could try?

What does groupabbrev look like? What does _['sequence-item'] look like? 
Can they ever be equal?

		--jcc

-- 
"Building Websites with Plone"
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com


More information about the Zope mailing list