NOTE
I am sorry if this is wrong place to post plugin information That I have developed. I believe this will help.
I am wondering if there any way to to set form fields automatically based on object.
I means if I have a object
user = {
text: ['text fields1', 'text fields2'],
radio: 1,
checkbox:false,
select: '4'
}
and a form
<form>
<input name='user.text.0' type='text' />
<input name='user.text.1' type='text' />
<input name='user.radio' type='radio' value='1'/>
<input name='user.radio' type='radio' value='2'/>
<input name='user.checkbox' type='checkbox' />
<select name='user.select'>
<option value='1'> 1 </option>
<option value='2'> 2 </option>
<option value='3'> 3 </option>
<option value='4'> 4 </option>
</select>
</form>
Is there any JavaScript library which automatically fill all the form fields?
I also want a method which return form as an object.
I means if I call that method it should return
{
text: ['text fields1', 'text fields2'],
radio: 1,
checkbox:false,
select: '4'
}
I have created a small JavaScript library.
jsfiddle
it has two methods
FormManager.setData(Element, data)andFormManager.getData(Element).You can set form fields using
FormManager.setDataand you can get form fields data as a object using FormManager.getData.it uses fields name to create object keys and wise-versa.
I developed this so that I should not read form fields one by one.