My basic Perl skills notwithstanding, glad I could help. With a bit more help from
fuzzyping with this
node here's a way to use H::T's LOOP feature to solve it another way (though I have used your concatenating method many times). The Perl:
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
use HTML::Template;
use strict;
my @datalist;
my $template = HTML::Template -> new(filename => "../htmlfilename.tmpl
+");
while (my @ary = $sth->fetchrow_array()) {
my %one_record = (
dataid => $ary[0],
datalisting => $ary[1],
);
push (@datalist, \%one_record);
}
$template->param(datalist => \@datalist);
print $template->output();
And the HTML snippet:
<select name="xxxxx" size="4">
<tmpl_if datalist>
<tmpl_loop name="datalist">
<option value="<tmpl_var name='dataid'>"><tmpl_var name='data
+listing'></option>
</tmpl_loop>
</tmpl_if>
</select>
Caveat: I did not test it with a database, but using trial data in the script it worked fine. And thanks for a good question, I learned something in the process of answering it! What PM's is all about. Good luck.
—Brad
"A little yeast leavens the whole dough."
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.