JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 3rd, 2003, 08:37 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
Moving to next tabindex on event

Ok,...I am trying to setup a script that will move my cursor to the next tabindex for a form field when the length of a string hits a certain length.

In other words, for my area code field. When the length hits 3, I want the cursor to move to the prefix phone number field.

I have the js code to check the length of the field. I am just not sure what "On" event to use in the form field tag itself.

Any Ideas?
__________________
-- Jason

Reply With Quote
  #2  
Old February 11th, 2003, 04:24 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Once you hit your field limit, the next line of your javascript should be;
"document.frmName.txtPhoneNumber.focus()"

Not sure about automatically jumping to the next tabIndex - i think u'll have to hardcode it.

Last edited by stumpy : February 11th, 2003 at 04:27 AM.

Reply With Quote
  #3  
Old March 2nd, 2005, 08:27 AM
detour detour is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 detour User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 56 sec
Reputation Power: 0
Jump to next control with JavaScript

Quote:
Originally Posted by stumpy
Once you hit your field limit, the next line of your javascript should be;
"document.frmName.txtPhoneNumber.focus()"

Not sure about automatically jumping to the next tabIndex - i think u'll have to hardcode it.



Here some code to get you going ;-)

<script>
function OnKeyPress(field, event)
{
if (event.keyCode == 13) {
for (i = 0; i < field.form.elements.length; i++)
if (field.form.elements[i].tabIndex == field.tabIndex+1) {
field.form.elements[i].focus();
if (field.form.elements[i].type == "text")
field.form.elements[i].select();
break;
}
return false;
}
return true;
}
</script>

AND this is your control:

<input type="text" name="Name" tabindex="2" onKeyPress="return OnKeyPress(this, event)" />

Reply With Quote
  #4  
Old March 2nd, 2005, 04:31 PM
Anibal Anibal is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 176 Anibal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 4 h 20 m 48 sec
Reputation Power: 4
Hey all...
Look, the easiest way to aproach is this

Code:
 
<script...> 
function moveto(obj1, chars, obj2){
if(obj1.value.length == chars)
  obj2.focus();
}
</script>
 
 
<html>
........
........
<form name="ff" .....>
  <input type="text" name="text1" onKeypress="moveto(this, 3, document.ff.text2);">
  <input type="text" name="text2">
</form>
........
........
</html>



Good Luck....

Anibal.

Reply With Quote
  #5  
Old March 2nd, 2005, 07:30 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Wow - this is an OLD thread - over 2 years old!
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #6  
Old March 3rd, 2005, 08:37 AM
Anibal Anibal is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 176 Anibal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 4 h 20 m 48 sec
Reputation Power: 4
Right!!! I haven't noticed that.....Damn, are we getting old or what!!

Quote:
Originally Posted by stumpy
Wow - this is an OLD thread - over 2 years old!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Moving to next tabindex on event


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway