/    Sign up×
Community /Pin to ProfileBookmark

onKeyPress event error

I am having an error with firefox not wanting to accept an on key up event. I know that you have to program things differently for IE and FF but am having trouble doing so. Here is my working code in IE.

there are several text fields that run this same function and some text fields that will not fun the function.

Thanks in advance for any help.

[code=html]
<input name=”Lname” type=”text” class=”input” id=”nameinput” tabindex=”2″ value=”” onKeyDown=”KeyCheck(form1)” />
[/code]

[CODE]
function KeyCheck(frm)
{
var KeyID = event.keyCode;
//alert(event.keyCode);
switch(KeyID)
{

case 13:
//document.Form1.cusLookup.currentValueIndices =1;
frm.cusLookup.focus();
frm.cusLookup.options[1].selected = “1”;
//document.Form1.L.value = “Ctrl”;
//
}
}
[/CODE]

This is the function i am trying to use but cant figure out how to call it from the html

[CODE]
function KeyCheck(e)
{
var KeyID = (window.event) ? event.keyCode : e.keyCode;
switch(KeyID)
{
case 13:
//document.Form1.cusLookup.currentValueIndices =1;
frm.cusLookup.focus();
frm.cusLookup.options[1].selected = “1”;
//document.Form1.L.value = “Ctrl”;
//
}
}
[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mityaJul 28.2009 — FF isn't quite as generous in the field of referencing events. IE lets you call the last event with event.[property] but with FF you need to pass the event physically to any function you want to reference it (or assign it to a function constant, e.g. myfuncname.myevent = evt, or a global variable) and reference it that way. Example:

[CODE] if (!document.all) document.captureEvents(Event.MOUSECLICK);

document.getElementById('someelement').onmouseclick = function() { dosomething(); }

function dosomething() {
dosomething.evt = evt; //from now on, the event can be references by calling dosomething.evt, from anywhere in your script
}[/CODE]
×

Success!

Help @keoflex spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...