Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript AutoSuggest Problem

Status
Not open for further replies.

alohaaaron

Programmer
Mar 27, 2008
80
US
Hi, I'm trying to modify the AutoSuggest function by Nicholas Zakas but am having trouble. Basically instead of having the auto suggest function load when the page loads, I want it to trigger on the current text box the user is typing in (i've tried onblur, onfocus, onclick) but it only seems to work when I click on the box, click out, and then click back in, I don't know why? Thanks for the help.

Here is a link to the example.

Here is the original function that works, mine is below.
/*
window.onload = function () {

var oTextbox = new AutoSuggestControl(document.getElementById("txt1"), new StateSuggestions());

}
*/

//doesn't work
function initFormEvents2(newid) {

var oTextbox = new AutoSuggestControl(document.getElementById(newid), new StateSuggestions());

}


</script>
</head>
<body>
<p>This third example builds upon the previous one. The main difference
is that the suggestions are case insensitive. Try typing &quot;miSSouri&quot; into
the textbox and see what pops up.</p>
<p><input type="text" id="txt1" onblur='initFormEvents2(this.id);'/></p>
</body>
</html>
 
Hi

Why you commented out that piece of code ? Of course the functionality is not initialized without that.

By the way, you not need the variable :
Code:
window.onload = function () {
  new AutoSuggestControl(document.getElementById("txt1"), new StateSuggestions());        
}

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top