This code will generate a list of names as you type into the input text field. It filters out names and only displays the names that have a match with the characters typed in. For example, typing in 'Jo' will match the names JO, JOAN, JOAN, JOANA, JOANE, etc. and display the names underneath the input field.
I have my names stored on the server in a text file called names.txt. The names are a compiled list from the US Census data. Here's a link to the text list.
My Javascript code is embedded in the HTML. As I type into the text box, on each onkeyup event, I execute my showHint function. Here is the HTML.
And the Javascript:
This makes a request to the server to run my python script without reloading the page. Here's the server side Python script that takes a string as input, and returns all names that have that string as the first few letters.
Every time I let go of a key, the Javascript inserts the text data from the Python script into the span element.