Merge branch 'master' of github.com:kivitendo/kivitendo-erp
[kivitendo-erp.git] / templates / webpages / gl / form_header.html
index 728c80f..ec17569 100644 (file)
@@ -4,22 +4,28 @@
 [%- USE L %]
 <script type="text/javascript">
   <!--
-  function setTaxkey(row) {
-    var accno  = document.getElementById('accno_' + row);
-    var taxkey = accno.options[accno.selectedIndex].value;
-    var reg = /--([0-9]*)/;
-    var found = reg.exec(taxkey);
-    var index = found[1];
-    index = parseInt(index);
-    var tax = 'taxchart_' + row;
-    for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
-      var reg2 = new RegExp("^"+ index, "");
-      if (reg2.exec(document.getElementById(tax).options[i].value)) {
-        document.getElementById(tax).options[i].selected = true;
-        break;
-      }
-    }
-  };
+function updateTaxes(row)
+{
+  var accno  = document.getElementById('accno_' + row);
+  var taxkey = accno.options[accno.selectedIndex].value;
+  var reg = /--([0-9]*)/;
+  var found = reg.exec(taxkey);
+  var index = found[1];
+  index = parseInt(index);
+  var tax = 'taxchart_' + row;
+  var taxkeyposition = taxkey.lastIndexOf(found[0]);
+  var account = taxkey.substr(0, taxkeyposition);
+
+  $.ajax({
+    url: 'gl.pl?action=get_tax_dropdown',
+    data: { accno: account,
+            selected_index: index},
+    dataType: 'html',
+    success: function (new_html) {
+                                $("#taxchart_" + row).html(new_html);
+                              },
+  });
+};
 
   function copy_debit_to_credit() {
     var txt = document.getElementsByName('debit_1')[0].value;