use innerHTML directly

This commit is contained in:
Arthur Lu 2022-12-19 18:21:48 -08:00
parent dc95d5092d
commit ce1119f14a

View File

@ -14,17 +14,15 @@ async function populateForm (node, type, vmid) {
let config = await request(`/nodes/${node}/${type}/${vmid}/config`); let config = await request(`/nodes/${node}/${type}/${vmid}/config`);
console.log(config); console.log(config);
addFormLine("cores", {label: "Cores:"}, {type: "number", value: config.data.cores, min: 1, max: 8192}); addFormLine("cores", "Cores", {type: "number", value: config.data.cores, min: 1, max: 8192});
addFormLine("memory", {label: "Memory"}, {type: "number", value: config.data.memory, min: 16}); addFormLine("memory", "Memory", {type: "number", value: config.data.memory, min: 16});
} }
function addFormLine (id, labelAttr, inputAttr) { function addFormLine (id, labelName, inputAttr) {
let labelWrapperDiv = document.createElement("div"); let labelWrapperDiv = document.createElement("div");
let label = document.createElement("label"); let label = document.createElement("label");
label.for = id; label.for = id;
for (let k in labelAttr) { label.innerHTML = labelName;
label.setAttribute(k, labelAttr[k])
}
labelWrapperDiv.append(label); labelWrapperDiv.append(label);
let labelContainer = document.querySelector("#labels"); let labelContainer = document.querySelector("#labels");
labelContainer.append(labelWrapperDiv); labelContainer.append(labelWrapperDiv);