<%doc> Example: <& /elements/select-city.html, #recommended country => $current_country, state => $current_state, county => $current_county, city => $current_city, #optional prefix => $optional_unique_prefix, onchange => $javascript, disabled => 0, #bool disable_empty => 1, #defaults to 1, set to 0 to disable the empty option empty_label => 'all', #label for empty option style => [ 'attribute:value', 'another:value' ], &> % if ( $cityflag ) { <% include('/elements/xmlhttp.html', 'url' => $p.'misc/cities.cgi', 'subs' => [ $pre. 'get_cities' ], ) %> % } else { % } <%init> my %opt = @_; foreach my $opt (qw( city county state country prefix onchange disabled empty_value )) { $opt{$opt} = '' unless exists($opt{$opt}) && defined($opt{$opt}); } $opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'}); my $pre = $opt{'prefix'}; my $onchange = $opt{'onchange'}; my $city_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : []; my @cities = (); if ( $cityflag ) { @cities = map { length($_) ? $_ : $opt{'empty_data_value'} } cities( $opt{'county'}, $opt{'state'}, $opt{'country'} ); push @$city_style, 'display:none' unless scalar(@cities) > 1; } my $style = scalar(@$city_style) ? 'STYLE="'. join(';', @$city_style). '"' : ''; <%once> my $sql = "SELECT COUNT(*) FROM cust_main_county". " WHERE city IS NOT NULL AND city != ''"; my $sth = dbh->prepare($sql) or die dbh->errstr; $sth->execute or die $sth->errstr; my $cityflag = $sth->fetchrow_arrayref->[0];