0.0.1 • Published 9 years ago
form-objectification v0.0.1
form-objectification
A simple jQuery plugin for creating objects from form input values.
Example
The HTML:
<form class="myform">
<input type="text" name="firstname" id="fname" value="John" />
<input type="text" name="lastname" id="lname" value="Doe" />
<input type="submit" />
</form>Your JS:
var data = $('.myform').objectifyForm();...which would result in a object looking something like:
data = {
'firstname' : 'John',
'lastname' : 'Doe'
};The plugin automatically goes for the name attribute but also accepts id:
var data = $('.myform').objectifyForm({
'selector' : 'id'
});...which would result in the following object due to the example above:
data = {
'fname' : 'John',
'lname' : 'Doe'
};Easy, peasy.
0.0.1
9 years ago