Emailid
Password
         
  
    Forgot password

New user Sign Up
 

 

Syntax error on a dropdownlist control                            

Author Name Status Posted Time
Fang Poon 3/15/2009 11:08:56 PM
Author is Offline

Hi everybody,
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);")
Thank you
Fang. 

Subject Author Status Date

Re: Syntax error on a dropdownlist control

Evzon Ologio 3/16/2009 12:08:38 AM

Re: Line 15 is

Fang Poon 3/16/2009 12:09:40 AM

Re: Sorry!

Fang Poon 3/16/2009 12:10:24 AM

Re: Please post your ASP.NET code-behind

Evzon Ologio 3/16/2009 12:11:04 AM

Re: Thanks so much for helping!

Fang Poon 3/16/2009 12:11:49 AM

Re: Have you declared DropDownList1?

Evzon Ologio 3/16/2009 12:12:32 AM
Related Forums
Optimizing Images
Get a Website Template for Free!!!
Get a Website Template for Free!!!
Do You Sell Your Templates on Ebay?
Template Tutorials





Home | About Us | Site Map | Privacy Policy