Skip to content

Instantly share code, notes, and snippets.

/.java Secret

Created Aug 3, 2015
Embed
What would you like to do?
var els = form.elements
for (var i = 0; i < len; i++) {
var el = els[i];
if (el.name === "") {
continue;
}
//only add successfull controls
if (!el.disabled) {
switch(el.type) {
case 'button':
case 'submit':
case 'reset':
case 'image':
case 'file':
break;
case 'select-one':
if (el.selectedIndex >= 0) {
addField(el.name,...);
}
break;
case 'select-multiple':
...
case 'checkbox':
case 'radio':
//only checked radio- an checkboxes are successfull controls
if (el.checked) {
addField(el.name, el.value || 'on');
}
break;
default:
//this is for any input incl. 'text', 'password', 'hidden', 'textarea'
var nodeName = el.nodeName.toLowerCase();
if (nodeName === "input" || nodeName === "select" ||
nodeName === "object" || nodeName === "textarea") {
addField(el.name, el.value);
}
break;
}
}
}
//concatenate the array
return qString.join("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment