--- application-orig.js	2023-08-05 23:20:44.216290675 +0200
+++ application.js	2023-08-05 23:22:23.968834103 +0200
@@ -687,6 +687,42 @@
   });
 }
 
+function getInputParaId(input) {
+    return `${input.name} ${input.value}`;
+}
+
+function replaceButKeepInput(targetId, newData) {
+    if (!targetId)
+        return;
+    let element = document.getElementById(targetId);
+    if (!element)
+        return;
+    let tmpElement = document.createElement("p");
+    tmpElement.innerHTML = newData;
+    let oldMap = new Map(
+        Array.from(element.querySelectorAll("input"))
+            .map(node => [getInputParaId(node), node.checked])
+    )
+    let newMap = new Map(
+        Array.from(tmpElement.querySelectorAll("input"))
+            .map(node => [getInputParaId(node), node.checked])
+    )
+    for (let input of element.querySelectorAll("input")) {
+        if (newMap.get(getInputParaId(input)) === undefined) {
+            // remember the checked state in a hidden input
+            input.type = "hidden";
+            // hidden input has to be additionally disabled to not get sent
+            input.disabled = !input.checked;
+            tmpElement.append(input);
+        }
+    }
+    element.innerHTML = tmpElement.innerHTML;
+    for (let input of element.querySelectorAll("input")) {
+        if (oldMap.get(getInputParaId(input)))
+            input.checked = true;
+    }
+}
+
 function observeSearchfield(fieldId, targetId, url) {
   $('#'+fieldId).each(function() {
     var $this = $(this);
@@ -700,7 +736,7 @@
           url: url,
           type: 'get',
           data: {q: $this.val()},
-          success: function(data){ if(targetId) $('#'+targetId).html(data); },
+          success: function(data){ replaceButKeepInput(targetId, data); },
           beforeSend: function(){ $this.addClass('ajax-loading'); },
           complete: function(){ $this.removeClass('ajax-loading'); }
         });
