4 field => 'myfield', # NAME property
6 labels => { # or 'option_labels'
7 # note: these will be escaped for you, don't escape them
12 options => [ 'AL', 'AK', 'AR' ],
13 curr_value => scalar( $cgi->param('myfield') ),
16 id => 'myid', # DOM id
19 size => 1, # to show multiple rows at once
20 style => '', # STYLE property
23 onchange => 'do_something()',
24 js_only => 0, # disables the whole thing
25 element_etc => '', # anything else to put in the <select> tag
29 % unless ( $opt{'js_only'} ) {
31 <SELECT NAME = "<% $opt{field} %>"
33 previousValue = "<% $curr_value %>"
34 previousText = "<% $labels->{$curr_value} || $curr_value |h %>"
40 <% $opt{'element_etc'} %>
43 % if ( $opt{options} ) {
45 % foreach my $option ( @{ $opt{options} } ) { #just arrayref for now
47 <OPTION VALUE="<% $option %>"
48 <% $opt{curr_value} eq $option ? 'SELECTED' : '' %>
50 <% $labels->{$option} || $option |h %>
55 % } else { #deprecated weird value hashref used only by reason.html
57 % my $aref = $opt{'value'}->{'values'};
58 % my $vkey = $opt{'value'}->{'vcolumn'};
59 % my $ckey = $opt{'value'}->{'ccolumn'};
60 % foreach my $v (@$aref) {
62 <OPTION VALUE="<% $v->$vkey %>"
63 <% ($opt{curr_value} eq $v->$vkey) ? 'SELECTED' : '' %>
72 </SELECT> <% $opt{'post_field_label'} %>
79 my $labels = $opt{'option_labels'} || $opt{'labels'};
81 my $curr_value = $opt{'curr_value'};
84 if ( $opt{'onchange'} ) {
85 $onchange = $opt{'onchange'};
86 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
87 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
88 #callbacks should act the same
89 $onchange = 'onChange="'. $onchange. '"' unless $onchange =~ /^onChange=/i;
92 $opt{'disabled'} = &{ $opt{'disabled'} }( \%opt )
93 if ref($opt{'disabled'}) eq 'CODE';
94 $opt{'disabled'} = 'DISABLED'
95 if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah?
97 my @style = ref($opt{'style'})
103 my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
105 my $size = $opt{'size'} ? 'SIZE='.$opt{'size'} : '';
107 my $multiple = $opt{'multiple'} ? 'MULTIPLE' : '';