I would like to convert an entire form of data to a javascript object.
<form id='myform'>
<input type='text' name='field1' value='foo'>
<input type='text' name='field2' value='bar'>
</form>
would convert to a javascript object...
{
field1: 'foo',
field2: 'bar'
}
In MooTools you can do easy trick how to convert all forms values into the Object:
var formObjects=$('myform').toQueryString().parseQueryString();
Convert to JSON:
var formJson=JSON.encode(formObjects);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With