$(document).ready(function () {
  $("#toCity").keyup(function () {
    let searchText = $(this).val();
    if (searchText != "") {
      $.ajax({
        url: "action.php",
        method: "post",
        data: {
          query: searchText,
        },
        success: function (response) {
          $("#show-lists").html(response);
        },
      });
    } else {
      $("#show-lists").html("");
    }
  });
  
  
  $(document).on("click", "a", function () {
    $("#toCity").val($(this).text());
    $("#show-lists").html("");
  });
});