summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-county.html
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements/select-county.html')
-rw-r--r--httemplate/elements/select-county.html166
1 files changed, 0 insertions, 166 deletions
diff --git a/httemplate/elements/select-county.html b/httemplate/elements/select-county.html
deleted file mode 100644
index 6d498be0a..000000000
--- a/httemplate/elements/select-county.html
+++ /dev/null
@@ -1,166 +0,0 @@
-<%doc>
-
-Example:
-
- include( '/elements/select-county.html',
- #recommended
- country => $current_country,
- state => $current_state,
- county => $current_county,
-
- #optional
- prefix => $optional_unique_prefix,
- onchange => $javascript,
- disabled => 0, #bool
- disable_empty => 1, #defaults to 1, disable the empty option
- empty_label => 'all', #label for empty option
- style => [ 'attribute:value', 'another:value' ],
- );
-
-</%doc>
-% if ( $countyflag ) {
-
- <% include('/elements/xmlhttp.html',
- 'url' => $p.'misc/counties.cgi',
- 'subs' => [ $pre. 'get_counties' ],
- )
- %>
-
- <SCRIPT TYPE="text/javascript">
-
- function opt(what,value,text) {
- var optionName = new Option(text, value, false, false);
- var length = what.length;
- what.options[length] = optionName;
- }
-
- function <% $pre %>state_changed(what, callback) {
-
- state = what.options[what.selectedIndex].value;
- country = what.form.<% $pre %>country.options[what.form.<% $pre %>country.selectedIndex].value;
-
- function <% $pre %>update_counties(counties) {
-
- // blank the current county list
- for ( var i = what.form.<% $pre %>county.length; i >= 0; i-- )
- what.form.<% $pre %>county.options[i] = null;
-
- // add the new counties
- var countiesArray = eval('(' + counties + ')' );
- for ( var s = 0; s < countiesArray.length; s++ ) {
- var countyLabel = countiesArray[s];
- if ( countyLabel == "" )
- countyLabel = '(n/a)';
- opt(what.form.<% $pre %>county, countiesArray[s], countyLabel);
- }
-
- var countyFormLabel = document.getElementById('<% $pre %>countylabel');
-
- if ( countiesArray.length > 1 ) {
- what.form.<% $pre %>county.style.display = '';
- //countyFormLabel.style.visibility = 'visible';
- countyFormLabel.style.display = '';
- } else {
- what.form.<% $pre %>county.style.display = 'none';
- //countyFormLabel.style.visibility = 'hidden';
- countyFormLabel.style.display = 'none';
- }
-
- //run the callback
- if ( callback != null ) {
- callback();
- } else {
- <% $pre %>county_changed(what.form.<% $pre %>county);
- }
- }
-
- // go get the new counties
- <% $pre %>get_counties( state, country, <% $pre %>update_counties );
-
- }
-
- </SCRIPT>
-
- <SELECT NAME = "<% $pre %>county"
- ID = "<% $pre %>county"
- onChange= "<% $onchange %>"
- <% $opt{'disabled'} %>
- <% $style %>
- >
-
-% unless ( $opt{'disable_empty'} ) {
- <OPTION VALUE="" <% $opt{county} eq '' ? 'SELECTED' : '' %>><% $opt{empty_label} %>
-% }
-
-% foreach my $county ( @counties ) {
-
- <OPTION VALUE="<% $county |h %>"
- <% $county eq $opt{'county'} ? 'SELECTED' : '' %>
- ><% $county eq $opt{'empty_data_value'} ? $opt{'empty_data_label'} : $county %>
-
-% }
-
- </SELECT>
-
-% } else {
-
- <SCRIPT TYPE="text/javascript">
- function <% $pre %>state_changed(what) {
- }
- </SCRIPT>
-
- <SELECT NAME = "<% $pre %>county"
- ID = "<% $pre %>county"
- STYLE = "display:none"
- >
- <OPTION SELECTED VALUE="<% $opt{'county'} |h %>">
- </SELECT>
-
-% }
-
-<%init>
-
-my %opt = @_;
-foreach my $opt (qw( 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'};
-
-
-# disable_cityupdate?
-my $onchange =
- ( $opt{'disable_cityupdate'} ? '' : $pre.'county_changed(this); ' ).
- $opt{'onchange'};
-
-my $county_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : [];
-
-my @counties = ();
-if ( $countyflag ) {
-
- @counties = map { length($_) ? $_ : $opt{'empty_data_value'} }
- counties( $opt{'state'}, $opt{'country'} );
-
- push @$county_style, 'display:none'
- unless scalar(@counties) > 1;
-
-}
-
-my $style =
- scalar(@$county_style)
- ? 'STYLE="'. join(';', @$county_style). '"'
- : '';
-
-</%init>
-<%once>
-
-my $sql = "SELECT COUNT(*) FROM cust_main_county".
- " WHERE county IS NOT NULL AND county != ''";
-my $sth = dbh->prepare($sql) or die dbh->errstr;
-$sth->execute or die $sth->errstr;
-my $countyflag = $sth->fetchrow_arrayref->[0];
-
-</%once>