I have a JSON object and a <form>
. If the JSON object has a property whose name matches the name of a form <input>
I want the input to display the value of this property. Is there a simple way to do this with JQuery?
var json = {foo: 'foo', bar: 'bar};
def form = $('#myform');
// something magical that assigns JSON property values to form inputs with matching names
The form in question looks something like:
<form id = "#myform" action="/foo/bar/">
<input name="foo"/>
<input name="bar"/>
</form>