JasonTC
05-30-2006, 07:37 PM
I've been searching on this issue for a couple hours, but nothing I've found has led me to a solution. I have the following function:
function submitEnter(buttonId, myfield, e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
// else return true;
alert('keycode: ' + keycode);
if (keycode == 13)
{
alert('enter was pressed');
document.getElementById(buttonId).click();
}
}
And the onKeyPress attribute:
onKeyPress="submitEnter('buttonId', 'fieldId');"
It works fine in IE, but not Firefox. Firefox gives the alert "keycode: undefined" for any key. Obviously, Firefox never knows when the enter key is pressed. I commented out the "else return true;" line because it was causing Firefox not to give an alert at all.
function submitEnter(buttonId, myfield, e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
// else return true;
alert('keycode: ' + keycode);
if (keycode == 13)
{
alert('enter was pressed');
document.getElementById(buttonId).click();
}
}
And the onKeyPress attribute:
onKeyPress="submitEnter('buttonId', 'fieldId');"
It works fine in IE, but not Firefox. Firefox gives the alert "keycode: undefined" for any key. Obviously, Firefox never knows when the enter key is pressed. I commented out the "else return true;" line because it was causing Firefox not to give an alert at all.