option selected

"Simon McCaughey" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <013401c4e545$a4c19270$70a1a02f@AtticPC>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.