On Fri, 21 Dec 2001, Martijn van den Burg wrote:
> This is how I do it:
>
> <SELECT multiple NAME=<TMPL_VAR NAME=QPARAM1> SIZE=6>
> <TMPL_LOOP NAME=LOOP1>
> <TMPL_IF NAME="SELECTED">
> <OPTION VALUE=<TMPL_VAR NAME=VALUE> SELECTED><TMPL_VAR NAME=DISPLAY>
> <TMPL_ELSE>
> <OPTION VALUE=<TMPL_VAR NAME=VALUE>><TMPL_VAR NAME=DISPLAY>
> </TMPL_IF>
> </TMPL_LOOP>
> </SELECT>
I generally prefer something like this:
<select ...>
<tmpl_loop options>
<option value="<tmpl_var value>"<tmpl_if selected> selected</tmpl_if>><tmpl_var
text></option>
</tmpl_loop>
</select>
or, if the <tmpl_if> looks too ugly, then:
<option value="<tmpl_var value>"<tmpl_var selected>>><tmpl_var text></option>
and set <tmpl_var selected> to either "" or " selected", depending on
the conditions.
The perl code is much the same as below.
> $template->param(
> [...]
>
> LOOP1 => [
> {'VALUE' => 'all', 'DISPLAY' => 'all', 'SELECTED' =>
> $query->param('profile_name') eq "all" ? 1 : 0 },
> {'VALUE' => 'student', 'DISPLAY' => 'student',
> SELECTED' => $query->param('profile_name') eq "student" ? 1 : 0 },
> {'VALUE' => 'coord', 'DISPLAY' => 'co\366rdinator',
> 'SELECTED' => $query->param('profile_name') eq "coord" ? 1 : 0},
> {'VALUE' => 'admin', 'DISPLAY' => 'administrator',
> 'SELECTED' => $query->param('profile_name') eq "admin" ? 1 : 0},
> ],
> QPARAM3 => "profile_name",
> CAT3 => "Profile",
>
> [...]
> );
Philip
--
Philosophy: A route of many roads leading from nowhere to nothing.
-- Ambrose Bierce
Visit my webpage at http://www.ncst.ernet.in/~philip/
Read my writings at http://www.ncst.ernet.in/~philip/writings/
MSN philiptellis Yahoo! philiptellis
AIM philiptellis ICQ 129711328
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]