Thread Zwei Array ein Hash mit CGI (18 answers)
Opened by bianca at 2010-06-28 17:44

pq
 2010-06-29 09:59
#139167 #139167
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
benutzt keiner CPAN:HTML_Tags?

Script:
Code (perl): (dl )
1
2
3
4
5
6
$htc->param(
    arrayref => [ 'opt_2', # selected
        ['opt_1', 'option 1'],
        ['opt_2', 'option 2'],
    ],
);


Template:
Code: (dl )
1
2
3
<select>
<%html_option arrayref %>
</select>

Ausgabe:
Code: (dl )
1
2
3
4
<select>
<option value="opt_1">option 1</option>
<option value="opt_2" selected="selected">option 2</option>
</select>


edit: klarer vorteil: hier ist automatisch schon das "selected" mit drin.
Last edited: 2010-06-29 10:09:18 +0200 (CEST)
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 Zwei Array ein Hash mit CGI