Home Jquery autocomplete, get the selected value from first textbox and populate the second textbox
Reply: 0

Jquery autocomplete, get the selected value from first textbox and populate the second textbox

user1223
1#
user1223 Published in July 18, 2018, 4:54 am

I wanted to populate the textbox based on the selected value in the first textbox autocomplete. However not sure how to get the selected value from first textbox and query the database for the list of values to show as autocomplete values in the second text box.

My jquery code so far:

$(document).ready(function() {
    $("#autocomplete").autocomplete({
             minLength: 7, 
             delay: 1000,
        source: function(request, response) {
            $.ajax({
                url: "autocomplete",
                dataType: "json",
                async:false,
                data: {
                    term : request.term,
                    // country_id : $("#country_id").val()
                },
                success: function(data) {
                    response(data);
                }

            });
        },
    });
});

HTML:

<input type="text" name="autocomplete-person" id="autocomplete-per" class="form-control" placeholder="Enter person name" />
  <input type="text" name="autocomplete-aadress" id="autocomplete-adrs" class="form-control" placeholder="show address of seelected name" />
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306377 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO