I have an object like this:
var settings = {
Name: "Fairy Tail",
Feature:
{
Translate: true,
Share: true
}
}
And a form
<form>
<input type="text" name="Name" />
<input type="checkbox" name="Feature.Translate" />
<input type="checkbox" name="Feature.Share" />
</form>
How can I make the object fill the form “automatically” (without setting the value of each field by hand)?
You can do it this way (jsfiddle for a more sophisticated example), assuming you have
settingsvariable set first:And this solution is not as limited as other solutions in the versions I have seen so far – it supports the case you have given and can be easily expanded to support different types of fields and more levels.