A listener will wait for user input in the textarea. For demonstration purposes, only every other row autocompletes. Enter anything on odd lines (no autocomplete), try starting even lines with digits (names will autocomplete).
- Using jQuery to set event listeners.
- Using jQuery Caret (jCaret) plugin (forked) to select the autocompleted text.