Created
November 28, 2015 21:58
-
-
Save flpms/cd981fa34e4b27a32e17 to your computer and use it in GitHub Desktop.
Simple way to parse a form to json with native code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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