469,917 Members | 1,873 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

New To JavaScript

Hello, I found some script which allows me to
emulate "type down" functionality on a dropdown box in a vb.Net program.
When I load it into my project I get a message box pop up
which the script is loaded which says "Expected ")". It
looks well formed to me. Here is the function

function divert_entry()
{
obj = window.event.srcElement;
//debugger;
if (obj.getAttribute("persistValue") == null)
obj.setAttribute("persistValue","");
var iKey;
var eAny_Event = window.event;

iKey = eAny_Event.keyCode;

var sChr = String.fromCharCode(iKey);
if (iKey == 13)
{
obj.setAttribute("persistValue","");
return true;
}

if (iKey == 8)
{
sDelete_Chr = obj.getAttribute("persistValue");
obj.setAttribute("persistValue",
sDelete_Chr.substring(0,sDelete_Chr.length - 1));
sChr = '';
}
obj.setAttribute
("persistValue",obj.getAttribute("persistValue" ) + sChr);
lookupItem(obj);
if (((iKey > 33 && iKey < 255) || (iKey
== 8)) && (iKey ! = 40) && (iKey != 38))
eAny_Event.returnValue = false;
}

What actually highlights in the error is the call to the
function which is loaded as follows:

drpNumbers.Attributes.Add("onkeydown", "return divert_entry()")

It highlights the "return divert_entry()"

Any ideas why?
..
Jul 20 '05 #1
1 1784

"JHeavey" <ji*******@hotmail.com> schreef in bericht
news:b7**************************@posting.google.c om...

What actually highlights in the error is the call to the
function which is loaded as follows:

drpNumbers.Attributes.Add("onkeydown", "return divert_entry()")

It highlights the "return divert_entry()"

Any ideas why?


Try passing it a function instead of a string, e.g.:

drpNumbers.Attributes.Add("onkeydown", function () { return
divert_entry() } );
JW

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.