New To JavaScript

J

JHeavey

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?
..
 
J

Janwillem Borleffs

JHeavey said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top