Skip to content

Instantly share code, notes, and snippets.

@flpms
Created November 28, 2015 21:58
Show Gist options
  • Save flpms/cd981fa34e4b27a32e17 to your computer and use it in GitHub Desktop.
Save flpms/cd981fa34e4b27a32e17 to your computer and use it in GitHub Desktop.
Simple way to parse a form to json with native code
var i, input, obj = {};
var inputs = document.querySelectorAll('form input');
for (i = 0; i < inputs.length; i++) {
input = inputs[i];
obj[input.id] = input.value;
}
console.log(obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment