[ZPT] <select><option selected> question

daniel.a.fulton@delphiauto.com daniel.a.fulton@delphiauto.com
Tue, 22 May 2001 12:51:16 +0800


is this the best way to do an <select><option selected> tag set? it works but I
thought there might
be a shorter route that I missed.

template_info = ZSQL method (sequence of templates by ID) -- ['ID', 'name',
'location']
locations = ZSQL method (sequence of locations by name) - ['ID', 'name', 'city',
 'country']

<select name="location">
        <span tal:define="template_location template_info/location"
                     tal:repeat="location here/locations">
              <span tal:condition="python:template_location==location.name">
                     <option tal:define="ID location/ID"
                                     tal:condition="location"
                                     tal:attributes="value string:${ID}"
                                     tal:content="location/name"
                                     value="" selected>Location Name</option>
              </span>
              <span tal:condition="python:template_location!=location.name">
                     <option tal:define="ID location/ID"
                                     tal:condition="location"
                                     tal:attributes="value string:${ID}"
                                     tal:content="location/name"
                                     value="">Location Name</option>
              </span>
        </span>
</select>

TIA,

Daniel