codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Trying to use .js file for dropdownlist autocomplete in ASP.NET application  bubberz at 16:48 on Wednesday, August 24, 2005
 

I'm trying to use a .js file to get autocomplete on a dropdownlist control in my ASP.NET application, but keep getting a syntax error.

The error on the .js file is:

Line 15, Char 1, Object Expected:

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++) {
var itm = document.all(DropDownList1).children[cnt].text;
if (itm.substring(0,keys.length).toLowerCase()==keys.toLowerCase())
{
document.getElementById(DropDownList1).selectedIndex = cnt;
break;
}
}
}
//document.all(DropDownList1).onchange();
}

In my Page_Load .aspx page, I've got:
DropDownList1.Attributes.Add("onkeyup", "javascript:return dd_onkeypress(this);")








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  onChange issue
•  Remote program execution using cgi-perl
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007