OpenAuth_server/views/shared/formdata.js

14 lines
478 B
JavaScript
Raw Normal View History

2018-11-06 19:48:50 +00:00
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;
}