Building ZPT forms
by
antonh
—
last modified
07-Sep-06 11:48 AM
I've been trying to set up a HTML form with a select field. I wanted to be able to pass a value in the URL (eg http://lawtec.net/app?comm=1) and have the select field selected on the form when the index matches the value passed.
It took a fair bit of playing around, and in the end, it turned out to be a type mismatch between the index and the value passed which was making it fail. Anyway, I've included it in case I need to do it again.
<select tal:attributes="onChange string:location.href='${here/absolute_url}
?comm='+this.options[this.selectedIndex].value"
tal:define="newsletters here/select_newsletters" name="comm">
<option tal:content="nl/description"
tal:attributes="value nl/communication_id;
selected python:int(comm) == int(nl.communication_id)">
Newsletter 1
</option>
</select>
Note that I actually split the first line up to fit it on this page properly