ajax-style xmlhttprequest state/county/country selector!
[freeside.git] / httemplate / edit / cust_main / select-state.html
diff --git a/httemplate/edit/cust_main/select-state.html b/httemplate/edit/cust_main/select-state.html
new file mode 100644 (file)
index 0000000..98e685a
--- /dev/null
@@ -0,0 +1,27 @@
+<%
+
+  my %opt = @_;
+  foreach my $opt (qw( county state country prefix onchange disabled )) {
+    $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
+  }
+
+%>
+
+<SELECT NAME="<%= $opt{'prefix'} %>state" onChange="<%= $opt{'prefix'} %>state_changed(this); <%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>>
+
+<% foreach my $state (
+     sort
+     map { $_->state }
+     qsearch( 'cust_main_county',
+              { 'country' => $opt{'country'} },
+              'DISTINCT ON ( state ) *',
+            )
+   ) {
+%>
+
+  <OPTION VALUE="<%= $state %>"<%= $state eq $opt{'state'} ? ' SELECTED' : '' %>><%= $state || '(n/a)' %>
+
+<% } %>
+
+</SELECT>
+