fix adding inputs when none are left

This commit is contained in:
trinkey 2024-02-20 16:21:23 -05:00
parent 39881ccf6a
commit 5cd12d6081

View file

@ -36,7 +36,7 @@ function add_input(key) {
let x = document.createElement("div") let x = document.createElement("div")
let q = [...document.querySelectorAll(`#${key} div[id^="${key}-"]`)]; let q = [...document.querySelectorAll(`#${key} div[id^="${key}-"]`)];
let i = Number(q[q.length - 1].dataset.id) + 1; let i = Number(q[q.length - 1] ? q[q.length - 1].dataset.id : "-1") + 1;
x.id = `${key}-${i}`; x.id = `${key}-${i}`;
x.setAttribute("data-id", i); x.setAttribute("data-id", i);