Skip to content

Instantly share code, notes, and snippets.

/.java Secret

Created August 3, 2015 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/95f9860b600c910fbd0c to your computer and use it in GitHub Desktop.
Save anonymous/95f9860b600c910fbd0c to your computer and use it in GitHub Desktop.
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