You suggest adding something like this:
$("#user").autocomplete({ source: "/item/user.php", minLength: 2, dataType: "json", select: function(event, ui) { $('#userId').val(ui.value); }, parse: function (data) { return $.map(arr, function (row, i) { return { data: row.id, value: row.value, result: row.value } }); }, });
Thus, the value in the selection option is userId, and text is userName.
Set a breakpoint when choosing a function and check the value of 'ui' on firebug .
source share