3 <% include('/elements/xmlhttp.html',
4 'url' => $p.'misc/counties.cgi',
5 'subs' => [ $opt{'prefix'}. 'get_counties' ],
9 <SCRIPT TYPE="text/javascript">
11 function opt(what,value,text) {
12 var optionName = new Option(text, value, false, false);
13 var length = what.length;
14 what.options[length] = optionName;
17 function <% $opt{'prefix'} %>state_changed(what, callback) {
19 state = what.options[what.selectedIndex].text;
20 country = what.form.<% $opt{'prefix'} %>country.options[what.form.<% $opt{'prefix'} %>country.selectedIndex].text;
22 function <% $opt{'prefix'} %>update_counties(counties) {
24 // blank the current county list
25 for ( var i = what.form.<% $opt{'prefix'} %>county.length; i >= 0; i-- )
26 what.form.<% $opt{'prefix'} %>county.options[i] = null;
28 // add the new counties
29 var countiesArray = eval('(' + counties + ')' );
30 for ( var s = 0; s < countiesArray.length; s++ ) {
31 var countyLabel = countiesArray[s];
32 if ( countyLabel == "" )
33 countyLabel = '(n/a)';
34 opt(what.form.<% $opt{'prefix'} %>county, countiesArray[s], countyLabel);
38 if ( callback != null )
42 // go get the new counties
43 <% $opt{'prefix'} %>get_counties( state, country, <% $opt{'prefix'} %>update_counties );
49 <SELECT NAME="<% $opt{'prefix'} %>county" onChange="<% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
50 % foreach my $county (
53 % qsearch('cust_main_county', { 'state' => $opt{'state'},
54 % 'country' => $opt{'country'},
59 <OPTION VALUE="<% $county %>"<% $county eq $opt{'county'} ? ' SELECTED' : '' %>><% $county %>
68 <SCRIPT TYPE="text/javascript">
69 function <% $opt{'prefix'} %>state_changed(what) {
73 <INPUT TYPE="hidden" NAME="<% $opt{'prefix'} %>county" VALUE="<% $opt{'county'} %>">
79 foreach my $opt (qw( county state country prefix onchange disabled )) {
80 $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
83 my $sql = "SELECT COUNT(*) FROM cust_main_county".
84 " WHERE county IS NOT NULL AND county != ''";
85 my $sth = dbh->prepare($sql) or die dbh->errstr;
86 $sth->execute or die $sth->errstr;
87 my $countyflag = $sth->fetchrow_arrayref->[0];