I've been struggling to implement an autocomplete textbox that utilizes a JSON file as its data source. Currently, the app is hosted on Google App Engine and the autocomplete function is based on an array of countries hardcoded into the code. However, I prefer to use a remote JSON data source, which will include additional key-value pairs such as "country":"USA", "capitol":"DC", "continent":"NorthAmerica", etc.
Does anyone have any insights on how I can achieve this? Would it be more practical to extract the JSON data and store it in a database like Google Datastore?
Below is the code snippet I'm currently using with the local array. Appreciate any help!
var countries = ["Afghanistan","Albania",...,"Zimbabwe"];
* { box-sizing: border-box; }
body {
font: 16px Arial;
}
.autocomplete {
position: relative;
display: inline-block;
}
/* CSS styles for autocomplete functionality */
<form autocomplete="off" action="/action_page.php">
<div class="autocomplete" style="width:300px;">
<input id="myInput" type="text" name="myCountry" placeholder="Country">
</div>
<input type="submit">
</form>