Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Pressing F2 key (Shift + Tab function) should go to PREVIOUS Field on the form - JavaScript

Posted on 2010-08-19
4
414 Views
Last Modified: 2012-05-10
Hi,

I have a form with some textboxes. I need to have a Javascript function that will do the following:

On pressing F2 function key should go to PREVIOUS textbox field (Shift + Tab function)  on the form.

Can you please provide me the Javascript code ?

Thanks
0
Comment
Question by:milani_lucie
  • 3
4 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 33475091
this link will help you in detecting the f2 keypress
http://www.javascriptkit.com/javatutors/javascriptkey2.shtml
http://www.quirksmode.org/js/keys.html

check this to see how to trigger a default event for a key programmatically
http://www.weask.us/entry/simulating-tab-keypress-javascript
0
 

Author Comment

by:milani_lucie
ID: 33517723
I did something like this. But does not solve my issue. Gives "JavaScript" error:
<html>
<head>
<script language="javascript">
function func(e)
{
var unicode = e.keyCode ? e.keyCode : e.charCode;
var evtobj=window.event ? event : e;
if (evtobj.shiftKey && unicode == 9)
{
document.form1..text1.focus();
}
}
</script>
<body>
<form name="form1">
<input type="text" name="text1" onkeyup="func(event);" />
<input type="text" name="text2" onkeyup="func(event);" />
<input type="text" name="text3" onkeyup="func(event);" />
</form>
</body>
</html>
 Thanks
0
 

Author Comment

by:milani_lucie
ID: 33765922
gurvinder372:
Can you please provide sample code ?
Thanks
0
 

Author Comment

by:milani_lucie
ID: 33995979
Any comment / help on this ?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question