From 7ff70a0bf66b7663d2a52ecf01ef85a2b81cdff6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Menne?= Date: Sun, 12 Jan 2025 14:17:48 +0100 Subject: [PATCH] Prevent infinite select creation --- .../static/georeport/recurse_selection.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/georeport/static/georeport/recurse_selection.js b/georeport/static/georeport/recurse_selection.js index 40b3cd3..0c78df2 100644 --- a/georeport/static/georeport/recurse_selection.js +++ b/georeport/static/georeport/recurse_selection.js @@ -1,9 +1,13 @@ +var level = 0 function getsubcats(element) { const id = element.id;; var level = 0; - if (id != "category") - level = id; + if (id == "category") + level = 0; + else + level = id + console.log(level); const rootselect = document.getElementById(id); @@ -34,7 +38,11 @@ function getsubcats(element) { } return } - let select = document.createElement("select"); + + let select = document.getElementById(level); + if (select != null) + select.remove(); + select = document.createElement("select"); select.id = level; select.name = select.id; select.value = ""; @@ -68,8 +76,8 @@ function getsubcats(element) { } -/*TODO Better ids for selection */ -/*TODO Labels for selection*/ -/*TODO tidy up*/ - +// TODO: name changes +// TODO: Better IDs for new selections +// TODO: Labels for selection*/ +// TODO: Tidy up -- 2.39.5