I am in the process of developing a form for the company intranet and i've recently added in code to capture the enter key event to prevent the page from automatically submitting. Along with this, i added code to move the focus to the next element in the tab index. When used in IE, the code works perfectly, but when i use it in firefox or chrome the focus jumps to the same box every time. I don't know what i'm doing wrong am i'm hoping someone can help me figure this out.
You can test the page at http://implicitarts.com/fandfwork/Lo...l/default.aspx
To start, go to the box for duty amount or freight charges and press enter
var evt = e ? e : window.event;
var bt = control.id;
if (evt.keyCode == 13)
function jumptoNext(field, event)
for (i = 0; i < field.form.elements.length; i++)
if (field.form.elements[i].tabIndex == field.tabIndex + 1)
if (field.form.elements[i].type == "text") field.form.elements[i].select();
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
I appreciate the reply, but if you found that error you saw that i coverted all values to a double number format, test to see if its a number, do processing, then call the toFixed() method. This function was just overlooked and i thank you for pointing out. I know that tab function is native to the browser, but if you refer to my original post, i stated that i capture the enter press event and move to the next field due to that event, which doesn't work correctly in all browsers.
There is something wrong with your function figureDisbursment(), which is called onblur from some of your elements. The focus jumps badly only from those fields which call that function onblur. If I remove (dynamically, using my FireBug) that functions from the onblur events, the focus jumps OK.
If some time, I will have a closer look.
I still think you have not managed the values in a proper way. You have a very intricate system to transform strings into numbers, using parseFloat() and isNaN(), while you could have simply used Number(). Number() returns 0 if the value is an empty string, while parseFloat() returns NaN, which gives you a supplementary trouble.
thank you for identifying a potential source. The cause for the call to the parsefloat() is because the for is used to generate bills to send to clients for billing; therefore the output had to be a decimal format. if there is a better way, please point me to the necessary resources.
call me crazy, but why would that function cause an issue in chrome and firefox, but not in internet exploer?