erstellung eines Edit forms für das Bearbeiten eines Items

This commit is contained in:
Technoir committed 2026-10-09 15:01:17 +02:00
1 parent 61c9348c60
commit 50852cf3a0
1 file changed
+27
@@ -14,6 +14,33 @@ export function addItem(itemAsJSON) {
list.appendChild(item.render());
}
export function createEditItemForm(textElement) {
const editForm = document.createElement("form");
const inputName = document.createElement("input");
const inputAmount = document.createElement("input");
const abortButton = document.createElement("button");
const saveButton = document.createElement("button");
inputName.setAttribute("name", "newItemName");
inputName.setAttribute("value", textElement.querySelector(".item__textName").textContent);
inputName.classList.add("editForm__name");
inputAmount.setAttribute("name", "newItemAmount");
inputAmount.setAttribute("value", textElement.querySelector(".item__textAmount").textContent);
inputAmount.classList.add("editForm__amount");
abortButton.textContent = "Abbrechen";
saveButton.textContent = "Speichern";
editForm.appendChild(inputName);
editForm.appendChild(inputAmount);
editForm.appendChild(saveButton);
editForm.appendChild(abortButton);
return editForm;
}
export function deleteItem(li) {
li.remove();
}