fix usps-validation misfire and inability to submit on change package too, RT#12377...
[freeside.git] / httemplate / elements / order_pkg.js
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();
+  }
+}