OpenAuth_server/FrontendLegacy/shared/formdata.js
Fabian Stamm 0453e461c9 Restructuring the Project
Updating dependencies
2023-04-07 19:54:47 +02:00

19 lines
505 B
JavaScript

export default function getFormData(element) {
let data = {};
if (
element.name !== undefined &&
element.name !== null &&
element.name !== ""
) {
if (typeof element.name === "string") {
if (element.type === "checkbox") data[element.name] = element.checked;
else data[element.name] = element.value;
}
}
element.childNodes.forEach((child) => {
let res = getFormData(child);
data = Object.assign(data, res);
});
return data;
}