[Zope] <SELECT> in forms.

Jim Washington jwashin@vt.edu
Fri, 14 Jan 2000 14:17:25 -0500


Hi, Guy

You need to provide value= in the <option> tag.

Additionally, you probably should set a default selection.  Sometimes
the variable is not sent at all if nothing is selected.

As an example, if the first item in the priority_choices list is an
acceptable default selection:

<SELECT NAME="priority" SIZE=7>
<dtml-in priority_choices>
<!-- start the option tag -->
  <OPTION
<!-- here we select if it is the first item -->
<dtml-if sequence-start>
  selected
</dtml-if>
<!-- give it a value -->
 value="<dtml-var sequence-item>"
<!-- end the option tag and provide the display -->
><dtml-var sequence-item>
<!-- </option> is not necessary -->
</dtml-in>
</SELECT>

For production, you probably will want to get rid of my comments...

Regards,

-- Jim Washington


> There is probably a really simple explanation for this, but I can't
> figure it out.  Any help is appreciated.
> 
> I am reworking the Search interface for a SQL Query, it works fine using
> the INPUT tag generated automatically.
> <input name="priority" width=30 value="">
> 
> However if I use the following select tag in place of the plain INPUT,
> the 'priority' variable is never pushed onto the request and my query
> method complains that it's missing.
> 
> <SELECT NAME="priority" SIZE=7>
> <dtml-in priority_choices>
>   <OPTION><dtml-var sequence-item></OPTION>
> </dtml-in>
> </SELECT>
> 
> In the above statement, 'priority_choices' is a 'lines' property of the
> containing folder.  This gives me the list of priorities, I'm looking
> for.
> 
> How do I properly use the SELECT tag to ensure the variable gets put
> into the REQUEST when the form is submitted? I looked at the Selection
> List How-To, but this doesn't seem to address this problem.