OpenAuth_server/views/shared/formdata.js
Fabian Stamm 51a8609880
All checks were successful
continuous-integration/drone/push Build is passing
Running prettier
2020-08-07 16:16:39 +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;
}