summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-time.html
blob: e7b404bbb641629518fc94a12869794e5ad32662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
% unless ( $opt{'js_only'} ) {
    <SELECT NAME="<% $opt{'field'} %>" SIZE="1" <%$disabled%> <%$onchange%> >
%     for ( my $t = 0; $t <=1440; $t += $increment ) {
        <OPTION VALUE="<% $t %>"
                <%    ( $curr_value eq '' && $t == $selected_default )
                   || $curr_value == $t
                     ? 'SELECTED' : ''
                %>
        ><% FS::sched_avail::pretty_time($t) %>
%     }
    </SELECT>
% }
<%init>

my %opt = @_;
my $increment = $opt{increment} || 30;
my $selected_default = $opt{selected_default};
my $disabled = $opt{'disabled'} || '';

my $curr_value = $opt{curr_value};

my $onchange = '';
if ( $opt{'onchange'} ) {
  $onchange = $opt{'onchange'};
  $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
  $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack.  all onchange
                                        #callbacks should act the same
  $onchange = 'onChange="'. $onchange. '"' unless $onchange =~ /^onChange=/i;
}

</%init>