calculate_qty (Formel): Input- und Formel-Feld auch als Dom-Id übergeben können
[kivitendo-erp.git] / templates / webpages / generic / calculate_qty.html
index d7a8abd..3d2910c 100644 (file)
@@ -1,18 +1,13 @@
 [%- USE T8 %]
 [%- USE HTML %]
-<body onload="[%- onload %]">
+<h1>[% title %]</h1>
 
  <form name="Form">
 
   <input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]">
-  <input type="hidden" name="input_id" value="[% HTML.escape(input_id) %]">
+  <input type="hidden" name="input_id"   value="[% HTML.escape(input_id) %]">
 
   <table width="100%">
-   <tr>
-    <th class="listtop">[% title %]</th>
-   </tr>
-   <tr height="5"></tr>
-
    <tr><td>[% 'Please insert object dimensions below.' | $T8 %]</td></tr>
 
    <tr>
  <script type="text/javascript">
    function calculate_qty() {
 [%- FOREACH row = VARIABLES %]
-     var [% row.name %] = parse_amount('[% myconfig.numberformat %]', document.getElementsByName("[% row.name %]")[0].value);
+     var [% row.name %] = parse_amount('[% MYCONFIG.numberformat %]', document.getElementsByName("[% row.name %]")[0].value);
 [%- END %]
      var result = [% formel %];
-     result = number_format(result, 2, '[% myconfig.numberformat %]');
-     window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result;
+     result = number_format(result, 2, '[% MYCONFIG.numberformat %]');
+     if (document.Form.input_id.value) {
+       window.opener.document.getElementById(document.Form.input_id.value).value = result;
+     } else {
+       window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result;
+     }
      self.close();
    }
 
@@ -87,6 +86,3 @@
      return arr_int[0] + sep + arr_int[1];
    }
  </script>
-
-</body>
-</html>