in reply to Re: HTML:Template Limitation?
in thread HTML:Template Limitation?
Now then, you say that you use 'the same type of code to build 6 other select lists' ... why not use one function to handle them all? ;) (and don't say because they have different 'business rules' ... if that's the case, do the extra specific stuff first, then call popup_menu()). Happy coding to ya. :)use strict; use warnings; use HTML::Template; use CGI qw(:standard); my @color = qw(red green blue black purple orange); my %valid = map {$_ => 1} @color; my $tmpl = HTML::Template->new(filehandle => *DATA); my $color = param('color'); my $select = popup_menu( -name => 'color', -values => [@color], -default => $color, ); $tmpl->param(error => 1) unless $valid{$color}; $tmpl->param( colors => $select, color => $color, ); print header, $tmpl->output; __DATA__ <form> <p> Pick a color: <tmpl_var colors> </p> <input type="submit"> </form> <tmpl_if color> <p><hr/></p> <tmpl_unless error> You picked <span style="color: <tmpl_var color>;"><tmpl_var color></span> <tmpl_else> Invalid choice, "<tmpl_var color>" </tmpl_unless> </tmpl_if>
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) 2Re: HTML:Template Limitation?
by digger (Friar) on Mar 19, 2003 at 15:48 UTC |