Home > Mobile >  Two autocomplete function in a single input text
Two autocomplete function in a single input text

Time:05-14

I have two autocomplete function , that work fine for different textboxes , I want to add these two two autocomplete function values in single text box ,
1st function :

$(function () {
$(".AccountSuplier").autocomplete({
    source: '/AccAddAcount/AutoSearchSupplierAcc'
});
});
//that I used with textbox like this :
<input asp-for="Supplier" >
           

2nd function :

$(function () {
 $(".AutoEmplyee").autocomplete({
    source: '/EmpAddEmp/AutoSearchEmploy'
 });
 });

<input asp-for="Emplyee" >

these two function work fine and give list of Supplier and Emplyees in different textboxes , Now I want to add these list in single textbox,

CodePudding user response:

I try this but it work only for 1st class and give list of Supplier

<input asp-for="User" >

CodePudding user response:

You would need to manually combine the two queries. Without testing, it would look something like this:

$(function () {
    $(".SupplierEmployee").autocomplete({
        source: function (request, response) {
            let supplier = $.get("/AccAddAcount/AutoSearchSupplierAcc", {
                term: request.term
            });

            let employee = $.get("/EmpAddEmp/AutoSearchEmploy", {
                term: request.term
            });

            $.when(supplier, employee).done(function (data1, data2) {
                response(data1.concat(data2));
            });
        }
    });
});
<input asp-for="Supplier" >        
  • Related