I followed this w3schools tutorial to build a form autocomplete (full code on the link):
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_autocomplete