i just wanted to ask if jQuery provide such function that can supply value or populate all data from object to form's input.
Lets say i have form below :
<form id="frm">
<input type="text" name="field1"/>
<input type="text" name="field2"/>
<input type="text" name="field3"/>
<input type="text" name="field4"/>
<input type="text" name="field5"/>
<input type="text" name="field6"/>
.... soon
</form>
Then i have object from server side
$.ajax({
success : function(response){
$("#frm").supply(response.data); // Something like that
}
});
Currently, i am using the function below to make it work.
$.fn.supply = function(data){
return this.each(function(){
var element = $(this);
$.each(data,function(k,v){
element.find('[name="'+k+'"]').val(v)
})
});
};
Is there a function like that on jQuery? i don't know what keyword should i use. Can't find anything on Google.