Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

Finishing my time tracker project...

I've used jquery-ui to autocomplete some edit fields.

It works very well, but I have not figured how to force the autocomplete to happen when the page loads if the editbox is full.

I've done this:

JavaScript
$( function() {
    $("#edUbi").autocomplete(
    {
      minlength: 1,
      source: function(request, response) {
        $.ajax({
          url: "autocompleteDatasource.php",
          dataType: "json",
          data: {
            term : request.term
          },
          success: function(data) {
            response(data);
          }
        });
      },
      focus: function(event, ui)
      {
        $("#edUbi").val(ui.item.name);
        return false;
      },
      select: function(event, ui)
      {
        var country = "";

        if (ui.item.country != null) country = ui.item.country + '\n';
        if (ui.item.id != null) id = ui.item.id;

        $("#taUbi").val(country + id);
        return false;
      }
    })
    .autocomplete("instance")._renderItem = function(ul, item){
      return $( "<li>" )
      .append( "<div>" + item.name + "</div>" )
      .appendTo( ul );
    };
  });


With this code, I can start typing into edUbi (the textBox) and a list appears with values that are like the written text.

Once I select an option from the list edUbi a textArea control gets filled with country and id (I've reduced the list, but all the location data is there).

Is it possible to execute the query and fill taUbi with the correct values when I load the page and the edUbi control gets filled?

How should I do it?

Any idea?

Thank you very much for your time and help!

What I have tried:

Multiple syntax, searched Internet to find a description of the way to do it without luck.
Posted
Updated 23-Oct-19 8:17am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900