[Petal] option selected

Simon McCaughey simonmcc at nortelnetworks.com
Sat Dec 18 21:07:54 GMT 2004


I can't seem to get a reasonable solution to the option selected problem, basically I'm going through a list, adding options for each item, and if the one is selected then add a selected attribute

this is what I'm doing:

<select name="category">
<option tal:repeat="cat cat_list" value="$cat/id">
    $cat/name
</option>
</select>

and what I think I need is :
<select name="category">
<option tal:repeat="cat cat_list" tal:attributes="selected if: eq: $cat/id $item/cat/id then: true else: false" value="$cat/id">
    $cat/name
</option>
</select>

This is my first attempt at this, please don't laugh, I just started today :)

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webarch.co.uk/pipermail/petal/attachments/20041218/22eec7b0/attachment.htm


More information about the Petal mailing list