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

Mark A. Robinson marcos@paladin-its.com
Tue, 21 May 2002 11:19:20 -0500


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=3D"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=3D"location=3Dmypage?ddlb_val=3Dthis.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=3D"id =3D=3D 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=3D"2"> then the ddlb preselects just
fine. What does python need in order to see a variable passed to a page
using URL?variable=3Dvalue=20

thanks all