i have an unknown numberof inupt text field and i give all of them a TABINDEX value from 1 to n now i ant to be able to move from one to the other using the given tab order but t with the keybord arrows as well how cn i do that? thnaks i nadvance peleg
@kitofersApr 14.2005 — #if i have reached the first or the lasttext box to know its lst and go to the first?[/QUOTE]
There are many ways to do this, one of the simplest probably being marking the last and the first input box by a unique ID ("last" and "first" or whatever) and the checking for this in the script [if (inputfield.id == "last"){}]. Don't really know how this fits into your scenario - whether you are not already using the id properties of the fields etc..
The "best" (but also most complicated) way of doing this would probably be writing a universal script, that determines the first/last status by either the tabIndex property (inputfield.tabIndex), or simply by the sequence of the input elements in the form.
@kitofersApr 14.2005 — #[code=php]<input type="text" onKeyDown="checkArrow(event);" /> // UPDATED: Was originally posted with onKeyPress, but apparently there are problems with this in IE - onKeyDown seems to solve the problem.
function checkArrow(event) { // left: 37, right: 39, up: 38, down: 40 if (event.keyCode == 37) alert("You pressed the LEFT ARROW key."); } [/code] Haven't tested this code, but it should work.. ?
@kitofersApr 14.2005 — #Sorry, apparently in Internet Explorer the onKeyPress is not triggered by pressing the arrow keys.. This works in Mozilla, though. Let me check, if there's some other way..
@kitofersApr 14.2005 — #Sorry, apparently in Internet Explorer the onKeyPress is not triggered by pressing the arrow keys.. This works in Mozilla, though. Let me check, if there's some other way..[/QUOTE] Ok, I found out that the onKeyPress doesn't always (or ever) capture the arrow key presses. Instead use onKeyDown (or onKeyUp).