Re: populating dropdown box from db

Mark Haney <markh-rOuQeLG7NUhWk0Htik3J/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
On 05/09/2012 11:49 AM, Theunis De Klerk wrote:

>>
> Hi,
>
> So does this work?
> [% FOREACH factory IN factory %] (Note plural in example below)

I don't know if that works or not.  I realized that if it did work I'd 
quickly get lost in the logic loop when I came back to it months from 
now.  Not quite sure what I was thinking when I wrote that.  Granted, it 
was just before lunch and I couldn't focus through noise of my stomach 
growling.

>
> I am also new to TT. But I would have done it like this :
>
> #PERL
> my $vars = { 'factories' => \@rows};
>
> #HTML
> <select name="factory">
> [% FOREACH factory IN factories %]
> <option value="">[% factory %]</option>
> [% END %]
> </select>
>
> I am not sure why you would want to wrap the FOREACH around the select.


Wrapping the select in the OP was a mistake on my part.  I actually 
fixed that just after sending the post.


-- 

Mark Haney
Software Developer/Consultant
AB Emblem
markh-rOuQeLG7NUhWk0Htik3J/[email protected]
Linux marius.homelinux 3.3.4-3.fc16.x86_64 GNU/Linux
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.