drop-down-list-box pre-selecting by query variable
Hi all, I have a HTML SELECT drop down list box (ddlb). It has a few items in it (OPTIONs). The value of each option is a simple number (first OPTION has a value="1", etc.) Below the SELECT is a table pulled from a database from the selection in the ddlb (a typical master/detail kind of screen). When the user selects a different item in the ddlb, I want the screen to reload and have the detail table reflect the new item in the SELECT ddlb. Everything is working just fine EXCEPT when the page reloads, the SELECT ddlb is not pre-selecting the change in the ddlb. I accomplish the page reloading by using a little javascript in the SELECT onchange event: onchange="location=mypage?ddlb_val=this.value;" so the page is reloaded with a variable called ddlb_val, and it is set to the id value from the ddlb selection. No prob. I have a dtml-var showing that the number is being passed just fine. The problem is occurring in the SELECT creation I use the following line to determine which item in the ddlb to select by default: <dtml-if expr="id == ddlb_val">selected</dtml-if> but it is as if that little bit of python cannot see the ddlb_val that was passed to the page. If I create another variable before the SELECT statement like <dtml-let ddlb_val="2"> then the ddlb preselects just fine. What does python need in order to see a variable passed to a page using URL?variable=value thanks all
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
participants (2)
-
Geir Bækholt -
Mark A. Robinson