ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trying to use .js file for dropdownlist autocomplete

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> .NET Programming (ASP.NET, VB.NET, C#)
View previous topic :: View next topic  
Author Message
bubberz



Joined: 24 Aug 2005
Posts: 4

PostPosted: Wed Aug 24, 2005 10:43 am    Post subject: Trying to use .js file for dropdownlist autocomplete Reply with quote

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);")
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Thu Aug 25, 2005 8:17 am    Post subject: Reply with quote

Can you please tell us, which line is line 15?
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
bubberz



Joined: 24 Aug 2005
Posts: 4

PostPosted: Thu Aug 25, 2005 12:29 pm    Post subject: Reply with quote

Line 15 is:

keys = keys + key;
Back to top
View user's profile Send private message
bubberz



Joined: 24 Aug 2005
Posts: 4

PostPosted: Thu Aug 25, 2005 4:18 pm    Post subject: Reply with quote

Sorry, the "Object Expected" is pointing to the HTML line of the .aspx page for the asp:dropdownlist tag, and not the .js file
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Fri Aug 26, 2005 6:58 am    Post subject: Reply with quote

Please post your ASP.NET code-behind and let me know which is line 15?
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
bubberz



Joined: 24 Aug 2005
Posts: 4

PostPosted: Fri Aug 26, 2005 9:34 am    Post subject: Reply with quote

Thanks so much for helping!

The code behind is:

DropDownList1.Attributes.Add("onkeypress", "javascript:dd_onkeypress(this);return false;")

Line 15 is the HTML of: <asp:dropdownlist
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Sat Aug 27, 2005 4:42 pm    Post subject: Reply with quote

Have you declared DropDownList1?
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> .NET Programming (ASP.NET, VB.NET, C#) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial