HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 16th, 2004, 10:08 AM
grdnwesl's Avatar
grdnwesl grdnwesl is offline
Fuzzy but Ferocious User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: The Restaurant at the end of the Universe
Posts: 222 grdnwesl User rank is Sergeant (500 - 2000 Reputation Level)grdnwesl User rank is Sergeant (500 - 2000 Reputation Level)grdnwesl User rank is Sergeant (500 - 2000 Reputation Level)grdnwesl User rank is Sergeant (500 - 2000 Reputation Level)grdnwesl User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 18 h 54 m 35 sec
Reputation Power: 13
Question Move to next field in form

I have a form with multiple fields. What I need to know is: If a field is a specific length (e.g. 3 character max) how do I automatically pass the cursor to the next field after the third character has been keyed?

Reply With Quote
  #2  
Old August 16th, 2004, 11:54 AM
coinhunter's Avatar
coinhunter coinhunter is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Battle Creek, Michigan
Posts: 352 coinhunter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 sec
Reputation Power: 5
Send a message via Yahoo to coinhunter
You can make use of the onKeyPress for text boxes & text areas, onChange for select option boxes, onClick for check boxes and radio buttons. It's not exactly perfect, but it does the job. Below is an example illustrating all three:
Javascript function:
Quote:
<script language="JavaScript">
function moveIT()
//This function moves the focus to the next field upon completing field.
{
if ( document.formname.textboxname.value.length == 3 )
{
document.formname.textboxname.focus();
}
if ( document.formname.textboxname.value.length == 7 )
{
document.formname.selectboxname.focus();
}
if (document.formname.selectboxname.options[0].selected == false)
{
document.formname.textareaname.focus();
}
if ( document.formname.textareaname.value.length == 50 )
{
document.formname.checkboxname.focus();
}
if (document.formname.checkboxname1.checked || document.formname.checkboxname2.checked)
{
document.formname.submit.focus();
}
}
HTML form elements:
Quote:
Textboxes/Textareas: <input type="text" name="textboxname" size="3" tabindex="1" maxlength="3" onKeyPress="moveIT()">

Selectboxes: <select id="selectboxname" name="selectboxname" onChange="moveIT()">

Checkboxes: <INPUT type="checkbox" name="yes" onClick="moveIT()">

Reply With Quote
  #3  
Old August 17th, 2004, 09:24 AM
grdnwesl's Avatar
grdnwesl grdnwesl is offline
Fuzzy but Ferocious User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: The Restaurant at the end of the Universe
Posts: 222 grdnwesl User rank is Sergeant (500 - 2000 Reputation Level)grdnwesl User rank is Sergeant (500 - 2000 Reputation Level)grdnwesl User rank is Sergeant (500 - 2000 Reputation Level)grdnwesl User rank is Sergeant (500 - 2000 Reputation Level)grdnwesl User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 18 h 54 m 35 sec
Reputation Power: 13
Smile That was what I needed!

That did the trick. Thanks for your help coinhunter

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Move to next field in form


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 4 hosted by Hostway