How to create a JavaScript autocomplete or typeahead feature?