Your data array is more complex than the normal for Autocomplete. I'm not sure it will work in that form. The documentation says "An array of objects with
label and
value properties:
[ { label: "Choice1", value: "value1" }, ... ]" I'd try a simpler array and get it working. Then if you must, add the "users" and tinker with users[j] j=0 to length kind of code to roll through. It might work, or . . .not?
Working on a simpler array, it would look like
- var data = [
- {"value":"123","label":"User 123","mail":"123@example.com"},
- {"value":"456","label":"User 456","mail":"456@example.com"},
- {"value":"789","label":"User 789","mail":"789@example.com"},
- ]
Your select: option will be along the lines of:
select: function (event, ui){
$("#your_id_4_emailid").val(ui.item.mail);
}
You didn't say whether you are using remote or local data, but it looks like local (included in the javascript), so my comments are along that line.