calculate_qty (Formel): Input- und Formel-Feld auch als Dom-Id übergeben können
[kivitendo-erp.git] / js / calculate_qty.js
index fb04cd7..01fa5bf 100644 (file)
@@ -1,19 +1,17 @@
-function calculate_qty_selection_window(input_name, alu, formel, row) {
+function calculate_qty_selection_window(input_name, input_id, formel_name, formel_id) {
   var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes";
-  var name = document.getElementsByName(input_name)[0].value;
-  if (document.getElementsByName(alu)[0].value == "1") {
-    var action = "calculate_alu";
-    var qty = document.getElementsByName("qty_" + row)[0].value;
-    var description = document.getElementsByName("description_" + row)[0].value;
-  }  else var action = "calculate_qty";
+  var action = "calculate_qty";
+  if (formel_id) {
+    var formel = $('#' + formel_id).val();
+  } else {
+    var formel = $('[name="' + formel_name + '"]').val();
+  }
   url = "common.pl?" +
+    "INPUT_ENCODING=UTF-8&" +
     "action=" + action + "&" +
-    "name=" + escape(name) + "&" +
-    "input_name=" + escape(input_name) + "&" +
-    "description=" + escape(description) + "&" +
-    "qty=" + escape(qty) + "&" +
-    "row=" + escape(row) + "&" +
-   "formel=" + escape(document.getElementsByName(formel)[0].value)
+    "input_name=" + encodeURIComponent(input_name) + "&" +
+    "input_id="   + encodeURIComponent(input_id)   + "&" +
+    "formel=" + encodeURIComponent(formel);
   //alert(url);
   window.open(url, "_new_generic", parm);
 }