hi i need to create a form where when i put a batch_num, i would like that the other 2 input text in the form, autofill with materialname and materialCode taken from a query/array i found this but it give me the error that autocomplete function doesn't exist:
Uncaught TypeError: $(...).autocomplete is not a function
How can i fix the error or make the autocomplete input?
$(function() {
var users = [{
"email": "[email protected]",
"name": "marie"
}, {
"email": "[email protected]",
"name": "miss"
}];
function handleAutocomplete(term) {
// use 'term' for custom filtering etc.
var options = $.grep(users, function(e){ return e.name.startsWith(term); });
return options;
}
$("#name").autocomplete({
minLength: 0,
source: function(request, response) {
var name = request.term;
var data = handleAutocomplete(name); /* get answers from somewhere.. */
response(data);
},
focus: function(event, ui) {
$("#name").val(ui.item.name);
return false;
},
select: function(event, ui) {
$("#name").val(ui.item.name);
$("#email").html(ui.item.email);
return false;
}
}).autocomplete("instance")._renderItem = function(ul, item) {
return $("<li>")
.append("<a>" + item.name + "<br>" + item.email + "</a>")
.appendTo(ul);
};
});