automatically move cursor

Posted on 2007-04-04
Last Modified: 2010-04-09
hi guys

I have a field called Judgment number which is a combination of three fields like this

<html:text  style="fieldheight"  property="J_TYPE_CODE" size="4" maxlength="2" />
<html:text  style="fieldheight"  property="J_SEQUENCE_NUMBER" size="15" maxlength="6" />
<html:text  style="fieldheight"  property="J_NUMBER_YEAR" size="4" maxlength="2"/>

When user enters something in the first text box J_TYPE_CODE, i want the cusror to be automatically moved to the next text box
J_SEQUENCE_NUMBER  and then after entering something in the second text box i want the cursor to automatically move

i have seen this feature in many websites , any idea how i can do that

Question by:jaggernat
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
  • 3
LVL 33

Expert Comment

ID: 18852924
<html:text  style="fieldheight"  property="J_TYPE_CODE" size="4" maxlength="2" onkeyup="if(this.value.length==this.value.maxLength)this.form['J_SEQUENCE_NUMBER'].focus();" />

<html:text  style="fieldheight"  property="J_SEQUENCE_NUMBER" size="15" maxlength="6" onkeyup="if(this.value.length==this.value.maxLength)this.form['J_NUMBER_YEAR'].focus();" />

... assumes the generated HTML has name properties that match the properties above.
LVL 33

Expert Comment

ID: 18852936
sorry, left out the elements array:

<html:text  style="fieldheight"  property="J_TYPE_CODE" size="4" maxlength="2"
onkeyup="if(this.value.length==this.value.maxLength)this.form.elements['J_SEQUENCE_NUMBER'].focus();" />

<html:text  style="fieldheight"  property="J_SEQUENCE_NUMBER" size="15" maxlength="6"
onkeyup="if(this.value.length==this.value.maxLength)this.form.elements['J_NUMBER_YEAR'].focus();" />

LVL 33

Accepted Solution

knightEknight earned 250 total points
ID: 18852963
DOH!  Still had a typo -- really sorry.  The maxLength property belongs to the field, not the value of the field:

<html:text  style="fieldheight"  property="J_TYPE_CODE" size="4" maxlength="2"
  onkeyup="if(this.value.length==this.maxLength)this.form.elements['J_SEQUENCE_NUMBER'].focus();" />

<html:text  style="fieldheight"  property="J_SEQUENCE_NUMBER" size="15" maxlength="6"
  onkeyup="if(this.value.length==this.maxLength)this.form.elements['J_NUMBER_YEAR'].focus();" />

LVL 10

Author Comment

ID: 18853273
thank you

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 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