Last active
June 27, 2017 19:45
-
-
Save rolfen/cb53eda59174d71f00b8fd804bef82a6 to your computer and use it in GitHub Desktop.
Serialize form to JSON - the simple way
This file contains 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
// credit: https://codepen.io/gabrieleromanato/pen/LpLVeQ | |
function parseInputs( elements ) { | |
var obj = {}; | |
for( var i = 0; i < elements.length; ++i ) { | |
var element = elements[i]; | |
var name = element.name; | |
var value = element.value; | |
if( name ) { | |
obj[ name ] = value; | |
} | |
} | |
return ( obj ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment