[Zope] How to retrieve the selection list
Curtis Maloney
curtis@cardgate.net
Tue, 9 Jan 2001 15:49:54 +1100
On Tuesday 09 January 2001 16:01, Angietel wrote:
> > The following is my selection list, where should i put the <dtml-var
> custcountry> in order to display the selected result.
>
Ooh... this one hurts.. (o8
You have to put "SELECTED" on the 'option' tag you want to be default.
This means iterating over your list with something like:
<dtml-in CountryList>
<option <dtml-if "_['sequence-item']==custcountry"> SELECTED</dtml-if>
value="<dtml-var sequence-item>"><dtml-var sequence-item>
</dtml-in>
If you don't already have the country list in an object somewhere, I
recommend adding a "lines" type property to either that object, or an
appropriate folder, and put them in there.
And remember... if "custcountry" doesn't exist.. this will break... do
putting a:
<dtml-unless custcountry>
<dtml-call "REQUEST.set('custcountry',' ')">
</dtml-unless>
at the top of the page won't hurt.
> <select name="custcountry" size="1" tabindex="9" style="HEIGHT: 22px;
> WIDTH: 293px">
>
> <option value="....."selected>Please select a country</option>
>
> <option value="Australia">Australia</option>
> <option value="Cambodia">Cambodia</option>
> <option value="Canada">Canada</option>
8< *snip* >8
> </select>
>
> Thank You!
Have a better one,
Curtis Maloney.