[Zope] drop-down-list-box pre-selecting by query variable

Geir Bækholt Geir Bækholt
Tue, 21 May 2002 20:35:45 +0200


Hello Mark, 

Tuesday, May 21, 2002, 6:19:20 PM, you wrote:

MAR> Hi all,
MAR> I have a HTML SELECT drop down list box (ddlb). It has a few items in it
MAR> (OPTIONs). The value of each option is a simple number (first OPTION has
MAR> a value="1", etc.)
[snip]

MAR> The problem is occurring in the SELECT creation I use the following line
MAR> to determine which item in the ddlb to select by default:
MAR>   <dtml-if expr="id == ddlb_val">selected</dtml-if>

Request-values encoded in the URL are strings by default..

either simply do "mypage?ddlb_val:int=2" in the url , or cast it to an
integer when you do the check ..

haven't done DTML in a year or two now (ZPT rule!), so i cannot remember if you
need to do the weird namespace-twiddling-thing for that , but it probably looks
somewhat like this :

<dtml-if expr="id == _.int(ddlb_val)">





-- 
Geir Bækholt                       web-developer
geirh@funcom.com             funcom oslo | webdev-team