I have more than a few... But here is one I like to reference: (super auto complete!)
for(i=0; i<wordarr.length; i++){
// As I am typing words into a textbox, I loop through a list of saved values so that (character by character) if the letters (in sequence) is contained in any word in my stored list; add to a clickable container; The clicked/selected item appears/copies into the textbox I am/was typing in:
if(wordarr[i].indexOf(text.toLowerCase())>=0){
autocomplete.innerHTML = autocomplete.innerHTML+"<a href='#' onclick=\"setText('"+wordarr[i]+"')\">"+wordarr[i]+"</a>"+"<br />";
};`
}