-<%
- my %opt = @_;
- foreach my $opt (qw( county state country prefix onchange disabled )) {
- $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
- }
-
- my $conf = new FS::Conf;
- my $countrydefault = $conf->config('countrydefault') || 'US';
-
-%>
-
-<%= include('/elements/xmlhttp.html',
+<% include('/elements/xmlhttp.html',
'url' => $p.'misc/states.cgi',
'subs' => [ $opt{'prefix'}. 'get_states' ],
)
what.options[length] = optionName;
}
- function <%= $opt{'prefix'} %>country_changed(what, callback) {
+ function <% $opt{'prefix'} %>country_changed(what, callback) {
country = what.options[what.selectedIndex].value;
- function <%= $opt{'prefix'} %>update_states(states) {
+ function <% $opt{'prefix'} %>update_states(states) {
// blank the current state list
- for ( var i = what.form.<%= $opt{'prefix'} %>state.length; i >= 0; i-- )
- what.form.<%= $opt{'prefix'} %>state.options[i] = null;
+ for ( var i = what.form.<% $opt{'prefix'} %>state.length; i >= 0; i-- )
+ what.form.<% $opt{'prefix'} %>state.options[i] = null;
// add the new states
var statesArray = eval('(' + states + ')' );
var stateLabel = statesArray[s+1];
if ( stateLabel == "" )
stateLabel = '(n/a)';
- opt(what.form.<%= $opt{'prefix'} %>state, statesArray[s], stateLabel);
+ opt(what.form.<% $opt{'prefix'} %>state, statesArray[s], stateLabel);
}
//run the callback
}
// go get the new states
- <%= $opt{'prefix'} %>get_states( country, <%= $opt{'prefix'} %>update_states );
+ <% $opt{'prefix'} %>get_states( country, <% $opt{'prefix'} %>update_states );
}
</SCRIPT>
-<SELECT NAME="<%= $opt{'prefix'} %>country" onChange="<%= $opt{'prefix'} %>country_changed(this); <%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>>
+<SELECT NAME="<% $opt{'prefix'} %>country" onChange="<% $opt{'prefix'} %>country_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
-<% foreach my $country (
- sort { ($b eq $countrydefault) <=> ($a eq $countrydefault)
- or code2country($a) cmp code2country($b) }
- map { $_->country }
- qsearch( 'cust_main_county',{}, 'DISTINCT ON ( country ) *', )
- ) {
-%>
+% foreach my $country (
+% sort { ($b eq $countrydefault) <=> ($a eq $countrydefault)
+% or code2country($a) cmp code2country($b) }
+% map { $_->country }
+% qsearch({
+% 'select' => 'country',
+% 'table' => 'cust_main_county',
+% 'hashref' => {},
+% 'extra_sql' => 'GROUP BY country',
+% })
+% ) {
- <OPTION VALUE="<%= $country %>"<%= $country eq $opt{'country'} ? ' SELECTED' : '' %>><%= code2country($country). " ($country)" %>
+ <OPTION VALUE="<% $country %>"<% $country eq $opt{'country'} ? ' SELECTED' : '' %>><% code2country($country). " ($country)" %>
-<% } %>
+% }
</SELECT>
+<%init>
+my %opt = @_;
+foreach my $opt (qw( county state country prefix onchange disabled )) {
+ $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
+}
+
+my $conf = new FS::Conf;
+my $countrydefault = $conf->config('countrydefault') || 'US';
+</%init>
+