combine ticket notification scrips, #15353
[freeside.git] / httemplate / elements / select-county.html
index 59f235a..6d498be 100644 (file)
@@ -58,15 +58,20 @@ Example:
 
         if ( countiesArray.length > 1 ) { 
           what.form.<% $pre %>county.style.display = '';
-          countyFormLabel.style.visibility = 'visible';
+          //countyFormLabel.style.visibility = 'visible';
+          countyFormLabel.style.display = '';
         } else {
           what.form.<% $pre %>county.style.display = 'none';
-          countyFormLabel.style.visibility = 'hidden';
+          //countyFormLabel.style.visibility = 'hidden';
+          countyFormLabel.style.display = 'none';
         }
 
         //run the callback
-        if ( callback != null ) 
+        if ( callback != null )  {
           callback();
+        } else {
+          <% $pre %>county_changed(what.form.<% $pre %>county);
+        }
       }
   
       // go get the new counties
@@ -78,7 +83,7 @@ Example:
 
   <SELECT NAME    = "<% $pre %>county"
           ID      = "<% $pre %>county"
-          onChange= "<% $opt{'onchange'} %>"
+          onChange= "<% $onchange %>"
           <% $opt{'disabled'} %>
           <% $style %>
   >
@@ -125,11 +130,13 @@ $opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'});
 
 my $pre = $opt{'prefix'};
 
-$opt{'style'} ||= [];
-my $style =
-  scalar(@{$opt{style}})
-    ? 'STYLE="'. join(';', @{$opt{style}}). '"'
-    : '';
+
+# disable_cityupdate?
+my $onchange =
+  ( $opt{'disable_cityupdate'} ? '' : $pre.'county_changed(this); ' ).
+  $opt{'onchange'};
+
+my $county_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : [];
 
 my @counties = ();
 if ( $countyflag ) {
@@ -137,17 +144,16 @@ if ( $countyflag ) {
   @counties = map { length($_) ? $_ : $opt{'empty_data_value'} }
                   counties( $opt{'state'}, $opt{'country'} );
 
-  # this is very hacky
-  unless ( scalar(@counties) > 1 ) {
-    if ( $opt{'disabled'} =~ /STYLE=/i ) {
-      $opt{'disabled'} =~ s/STYLE="([^"]+)"/STYLE="$1; display:none"/i;
-    } else {
-      $opt{'disabled'} .= ' STYLE="display:none"';
-    }
-  }
+  push @$county_style, 'display:none'
+    unless scalar(@counties) > 1;
 
 }
 
+my $style =
+  scalar(@$county_style)
+    ? 'STYLE="'. join(';', @$county_style). '"'
+    : '';
+
 </%init>
 <%once>