Could you please help me on how to fire a javascript function txtID() on select of an item from autocomplete dropdown
Below is the snippet
$("Autotxt").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Webservice.asmx/GetNames",
data: "{'prefixText':'" + request.term + "'}",
dataType: "json",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('|')[0],
val: item.split('|')[1]
}
}))
},
error: function (result) {
alert("Due to unexpected errors we were unable to load data");
},
failure: function (response) {
alert("Due to unexpected errors we were unable to load data");
}
}).result(function (event, ui) {
txtID(ui.item.val);
});
},
minLength: 2
});
function txtID(val)
{
alert(val)
}
Any help would be much appreciated.
Thanks
Use the
selectevent of the autocomplete:Autocomplete Select Event