Thread HTC: Alternative zu LOOP (3 answers)
Opened by Froschpopo at 2007-07-20 04:49

pq
 2007-07-20 12:11
#393 #393
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
da die auswahlfelder in der regel aus der datenbank kommen, ist hier meine
empfohlene lösung (aus Perlmonks:627497):
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
my @cities = qw(Berlin Hamburg North_Adams);

my $htc = HTML::Template::Compiled->new(
   scalarref => \"<select><%html_option cities %></select>",
   plugin => [qw(::HTML_Tags)],
);
$htc->param(
   cities => [
       1, # selected
       map { [$_, $cities[$_]] } 0..$#cities],
);


output:

Code: (dl )
1
2
3
<select><option value="0" >Berlin</option>
<option value="1" selected="selected">Hamburg</option>
<option value="2" >North_Adams</option></select>

und nun sag, das sei nicht bequem...\n\n

<!--EDIT|pq|1184919440-->
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread HTC: Alternative zu LOOP