Trying to use .js file for dropdownlist autocomplete in ASP.NET application

bubberz

Newcomer
Joined
Aug 25, 2005
Messages
2
When I run the page, I get an "Object Expected" on line 16, which points to the asp:dropdownlist line in the HTML of the .aspx page.

Here's the .js file:

var keys;
var timeStamp;
timeStamp = new Date();
function dd_onkeypress(DropDownList1) {
* var key = event.keyCode;
* event.returnValue=false;
*//a-z, A-Z, 0-9
* if ((key>=97 && key<=122) || (key>=65 && key<=90) || (key>=48 && key<=57)) {
* ********key = String.fromCharCode(key);
* ********var now = new Date();
* ********var diff = (now.getTime() - timeStamp.getTime());
* ********timeStamp = new Date();
* ********//1 seconds = 1000 milliseconds<BR>***
* ********if (diff > 1000) {
* ********************keys = key;****
* *********************} else {
* *********************keys = keys + key;
* *********************}
* *********************var cnt;
* *********************//for (cnt=0;cnt<document.all(DropDownList1).children.length;cnt++)
* *********************//for (cnt=0;cnt<DropDownList1.children.length;cnt++)
* *********************for (cnt=0;cnt<DropDownList1.options.length;cnt++) {
********************** var itm = DropDownList1.options[cnt].text;
********************** if
(itm.substring(0,keys.length).toLowerCase()==keys.toLowerCase())
* *********************{
* *********************//var itm = document.all(DropDownList1).children[cnt].text;
* *********************//var itm = DropDownList1.children[cnt].text;
* *********************//if (itm.substring(0,keys.length).toLowerCase()==keys.toLowerCase())
{
//document.getElementById(DropDownList1).selectedIndex = cnt;
DropDownList1.selectedIndex = cnt;
break;
}
}
}
//document.all(DropDownList1).onchange();
}

For the Page_Load in the .aspx.vb file I've got:
DropDownList1.Attributes.Add("onkeyup", "javascript:return dd_onkeypress('DropDownList1');")
 
mark007 said:
Is this a javscript or asp.net error? Have you made sure your dropdown is declared?

Well, if I comment out the Page_Load .aspx code that calls the .js file's function, then the page doesn't throw an error, and the dropdownlist acts as it should from the .NET toolbox
 
Back
Top