By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

how to control the focus in ids using tab in a loop

P: 1
i have written this code n using it i am able to control focus in my order.but now i want them to appear in loop.i mean from id 1 to 2,then 3,then again from 3 to 1.thus in a loop.what code should i add????

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Required Field</title>
  4. <script type="text/javascript">
  5.   function testing(event,number) 
  6.     { 
  7.         if( event.keyCode ==9 ) 
  8.         { 
  9.             var wow = document.getElementById(number); 
  10.             wow.focus(); 
  11.         }         
  12.     } 
  13. </script>
  14. </head>
  15. <body onkeydown="if (event.keyCode==13) {event.keyCode=9; return event.keyCode }">
  16. <form>
  17.  <input id="11" type="text" tabindex="1" onkeyup="testing( event, 22)" /> 
  18.           <input id="22" type="text" tabindex="2" onkeyup="testing( event, 33)" /> 
  19.           <input id="33" type="text" tabindex="3" onkeyup="testing( event, 11)" /> 
  20.  
  21.  </form> 
  22. </script>
  23. </body>
  24. </html>
Oct 19 '11 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
There's a few things wrong with your code. It seems to be IE only for a start. Check out this similar thread which should help: http://bytes.com/topic/javascript/an...y-tab-keypress
Oct 21 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.