fixed updating checkbox value

This commit is contained in:
RaffaelW 2024-11-03 00:37:21 +01:00
parent 2aeef79a0f
commit d3e405c35c
2 changed files with 8 additions and 3 deletions

View file

@ -22,9 +22,14 @@ function writeDataToInput(data) {
console.log("write data", typeof data);
for (const [key, value] of Object.entries(data)) {
const element = document.querySelector(`[name=${key}]`);
console.log(element);
console.log(key, element);
if (element.type === "checkbox") {
element.checked = value;
} else {
element.value = value;
}
}
// send "change" event
form.dispatchEvent(new Event("change", { bubbles: true }));
}