Support radio, checkbox and select in form

This commit is contained in:
Biser Stoilov
2018-02-17 19:14:35 +02:00
committed by GitHub
parent 0c7af354fd
commit b351647313

View File

@@ -50,8 +50,26 @@ var formAction = function(el, event) {
// jscs:disable disallowImplicitTypeConversion // jscs:disable disallowImplicitTypeConversion
if (!!element.name && element.attributes !== undefined && element.tagName.toLowerCase() !== "button") { if (!!element.name && element.attributes !== undefined && element.tagName.toLowerCase() !== "button") {
// jscs:enable disallowImplicitTypeConversion // jscs:enable disallowImplicitTypeConversion
if ((element.attributes.type !== "checkbox" && element.attributes.type !== "radio") || element.checked) { var elementType;
paramObject.push({name: encodeURIComponent(element.name), value: encodeURIComponent(element.value)}) if (element.tagName.toLowerCase() === "input") {
if (element.type === "text") {
elementType = "input";
}
if (element.type === "checkbox") {
elementType = "checkbox";
}
if (element.type === "radio") {
elementType = "radio";
}
}
if (element.tagName.toLowerCase() === "select") {
elementType = "select";
}
if ((elementType !== "checkbox" && elementType !== "radio") || element.checked) {
paramObject.push({
name: encodeURIComponent(element.name),
value: encodeURIComponent(element.value)
})
} }
} }
} }