alohaaaron
Programmer
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 "miSSouri" into
the textbox and see what pops up.</p>
<p><input type="text" id="txt1" onblur='initFormEvents2(this.id);'/></p>
</body>
</html>
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 "miSSouri" into
the textbox and see what pops up.</p>
<p><input type="text" id="txt1" onblur='initFormEvents2(this.id);'/></p>
</body>
</html>