I'm gonna get hung for this one ;)

$sql = "SELECT id,name,CASE WHEN id = 123 THEN 'SELECTED' END AS selected
FROM sometable";
$prepare/execute/yada yada
$tmp->param(LIST => $sth->fetchall_arrayref({}));

where LIST is a list in HTML::Template format in the template.
that might look like this.

        <TMPL_LOOP NAME=OPEN_LIST>
          <select value="<TMPL_VAR NAME=id>" <TMPL_VAR
NAME=selected>><TMPL_VAR NAME=name></td>
        </TMPL_LOOP>

i kinda rushed that, but you get the gist.




>> -----Original Message-----
>> From: Jaclyn Whitehorn [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, April 02, 2003 7:21 PM
>> To: Tim Howell
>> Cc: [EMAIL PROTECTED]
>> Subject: Re: [cgiapp] Setting values in a select...
>>
>>
>> Generally, when doing dynamic select boxes, I just make the first
>> (default) entry the dynamic one, then do the whole list below that.  It
>> does mean that the one you want to be the default is listed twice (once
>> at the top and once in the list), but no one seems to mind much...
>>
>> Jaclyn
>>
>> On Wednesday, April 2, 2003, at 06:04  PM, Tim Howell wrote:
>>
>> > This isn't strictly a CGI::App question, but I know that a lot of us
>> > are
>> > using HTML::Template, so here goes: is there a good way to set the
>> > initial value in an HTML select using HTML::Template parameters?  I've
>> > got a select with 100 options (integers 0-100), and I'm looking for a
>> > simple way to populate it from the DB that's driving this app.
>> >
>> > Ideas?
>> >
>> > Thanks!  =)
>> >
>> > --TWH
>>
>>
>> ---------------------------------------------------------------------
>> Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to