...

View Full Version : Using onKeyDown with Tab key



apowers20
07-08-2005, 11:18 PM
Hi,

When I do the following in my form:

EG:
OnKeyDown="javascript: if(event.keyCode == 9){fieldname.focus()}"

It tabs to the wrong spot on the form. Likewise when I change the fieldname to any other field name in the form. What I want is to be able to vertically tab down the page so a user can input their data (The inputs are in 2 columns). The left side is a 'bill to' and the right side is a 'ship to'. I want all the bill to stuff filled out first before going to the second column.

Not exactly sure why this is not working, but any help would be apprecaited. Thanks.

enumerator
07-09-2005, 12:11 AM
Try defining tabindex attributes for the elements.

apowers20
07-09-2005, 12:38 AM
Well that did it. Thanks for the advice, didn't realize it was that easy.

On a side note, I think it's lame that the tab key is so gosh darn hard to define with JavaScript. Oh well, thanks!

enumerator
07-09-2005, 01:32 AM
On that note, controlling the event return value is key.


onkeydown="return event.keyCode == 9 ? fieldname.focus() || false : true"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum