I have data object that contains names. These names are taken from tr object and need to filled inside form element. Now data object has exact names as input element are in selected form.
Now I want to iterate through object and find input element with that name and fill its value.
Here is code
<form id="newItems">
<input class="form-control" name="Name" placeholder="Enter name" type="text">
<input class="form-control" name="Price" placeholder="Enter price" type="text">
</form>
//Data Object
var data = {
Name : "name",
Price : 50
};
for(var key in data){
if (data.hasOwnProperty(key)) {
console.log($('#'+modalId).find('input[name=key]'));return;
}
So far this return input element with name = key. But thats not what I need. I need whats inside key.
$('#'+modalId).find('input[name='+key+']').val()or$('#'+modalId).find('input[name='+key+']')[0].value