Немного неясно, чего вы пытаетесь достичь.Рассмотрим следующий пример:
$(function() {
var terms = [{
label: "Label 1",
value: "Value 1",
id: 1001
}, {
label: "Label 2",
value: "Value 2",
id: 1002
}, {
label: "Label 3",
value: "Value 3",
id: 1003
}];
$("#searchterms").autocomplete({
minLength: 2,
source: terms,
focus: function(event, ui) {
$("#searchterms").val(ui.item.label);
$("#productid").val(ui.item.id);
console.log("focus: " + ui.item.id);
return false;
},
select: function(event, ui) {
$("#searchterms").val(ui.item.value);
$("#productid").val(ui.item.id);
console.log("select: " + ui.item.id);
return false;
},
autoFocus: true,
delay: 3000
});
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="ui-widget">
<label for="searchterms">Search: </label>
<input type="text" id="searchterms" />
<input type="text" id="productid" />
</div>
Кажется, это делает то, что вы хотите, но я не уверен, какую ссылку вы пытаетесь создать.
Надеюсь, это поможет.