I want to pass value from jquery to my html code.
function setMembers(members){
var members = members;
$('.member-search').autocomplete({
source: function (request, response) {
var regex = new RegExp(RegExp.escape(request.term), "i");
var recs = $.grep(members, function (obj) {
return ((regex.test(obj.first +" "+ obj.last)))
})
response($.map(recs, function (item) {
return {
label: item.first + " " + item.last,
value: item.first + " " + item.last,
id: item.id
}
}));
},
}
Here in return I passed item.first and item.last as value and item.id as id. I want to pass this id value to my html input tag value. This is my html.
<input type="text" class="form-control member-search" placeholder="Choose team member.." id="assigned_to" name="assigned_to" value="">
I can pass item.last and item.first but not item.id. Is there any way to do that. If I use item.id as value of return statement I can pass it to input tag value, But my auto complete out put is wrong. It shows user ID as below.
