[Zope] selected in select lists
J Cameron Cooper
zope-l at jcameroncooper.com
Wed Oct 12 16:10:32 EDT 2005
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? 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
--
"Building Websites with Plone"
http://plonebook.packtpub.com/
Enfold Systems, LLC
http://www.enfoldsystems.com
More information about the Zope
mailing list