fix usps-validation misfire and inability to submit on change package too, RT#12377...
authorivan <ivan>
Mon, 11 Apr 2011 23:06:16 +0000 (23:06 +0000)
committerivan <ivan>
Mon, 11 Apr 2011 23:06:16 +0000 (23:06 +0000)
httemplate/elements/order_pkg.js [new file with mode: 0644]
httemplate/misc/change_pkg.cgi
httemplate/misc/order_pkg.html

diff --git a/httemplate/elements/order_pkg.js b/httemplate/elements/order_pkg.js
new file mode 100644 (file)
index 0000000..2c13ed2
--- /dev/null
@@ -0,0 +1,28 @@
+function enable_order_pkg () {
+  var form = document.OrderPkgForm;
+  var discountnum = form.discountnum;
+
+  if ( form.pkgpart.selectedIndex > 0 ) {
+    form.submitButton.disabled = false;
+    if ( discountnum ) {
+      if ( form.pkgpart.options[form.pkgpart.selectedIndex].getAttribute('data-can_discount') == 1 ) {
+        form.discountnum.disabled = false;
+      } else {
+        form.discountnum.disabled = true;
+      }
+    }
+  } else {
+    form.submitButton.disabled = true;
+    if ( discountnum ) { form.discountnum.disabled = true; }
+  }
+}
+
+function standardize_new_location() {
+  var form = document.OrderPkgForm;
+  var loc = form.locationnum;
+  if (loc.type == 'select-one' && loc.options[loc.selectedIndex].value == -1){
+    standardize_locations();
+  } else {
+    form.submit();
+  }
+}
index ec10b85..8f0067d 100755 (executable)
@@ -1,5 +1,7 @@
 <% include('/elements/header-popup.html', "Change Package") %>
 
+<SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
+
 <% include('/elements/error.html') %>
 
 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/change-cust_pkg.html" METHOD=POST>
 %>
 
 <BR>
-<INPUT NAME="submitButton" TYPE="button" VALUE="Change package" onClick="this.disabled=true; standardize_locations();">
+<INPUT NAME    = "submitButton"
+       TYPE    = "button"
+       VALUE   = "Change package"
+       onClick = "this.disabled=true; standardize_new_location();"
+       <% scalar($cgi->param('pkgpart')) ? '' : 'DISABLED' %>
+>
 
 </FORM>
 </BODY>
index 17db187..964441a 100644 (file)
@@ -5,33 +5,7 @@
 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
 
-<SCRIPT TYPE="text/javascript">
-
-  function enable_order_pkg () {
-    if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
-      document.OrderPkgForm.submitButton.disabled = false;
-      if ( document.OrderPkgForm.pkgpart.options[document.OrderPkgForm.pkgpart.selectedIndex].getAttribute('data-can_discount') == 1 ) {
-        document.OrderPkgForm.discountnum.disabled = false;
-      } else {
-        document.OrderPkgForm.discountnum.disabled = true;
-      }
-    } else {
-      document.OrderPkgForm.submitButton.disabled = true;
-      document.OrderPkgForm.discountnum.disabled = true;
-    }
-  }
-
-  function standardize_new_location() {
-    var form = document.OrderPkgForm;
-    var loc = form.locationnum;
-    if (loc.type == 'select-one' && loc.options[loc.selectedIndex].value == -1){
-      standardize_locations();
-    } else {
-      form.submit();
-    }
-  }
-
-</SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
 
 <% include('/elements/error.html') %>
 
 % my $onclick = $cgi->param('lock_locationnum')
 %                 ? 'document.OrderPkgForm.submit()'
 %                 : 'standardize_new_location()';
-<INPUT NAME="submitButton"
-       TYPE="button"
-       VALUE="Order Package"
+<INPUT NAME    = "submitButton"
+       TYPE    = "button"
+       VALUE   = "Order Package"
        onClick = "this.disabled=true; <% $onclick %>;"
        <% $pkgpart ? '' : 'DISABLED' %>
 >