• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Dynamic Forms > 8.7. Advancing Text Field Focus with the Enter Key

Advancing Text Field Focus with the Enter Key

NN 4, IE 4

Problem

You want to use the Enter/Return key in a text field to give focus to the next text field in the form.

Solution

Include an onkeypress event handler in each field that needs to advance focus to another field in the form. The event handler should invoke the focusNext( ) function described in the Discussion. The event handler must pass arguments for the form reference, the name of the next field in sequence, and (for the W3C event model in NN) the event object. For example, the event handler in a field called name1 directs focus to field name2 in the following:

<input type="text" name="name1" id="name1" 
    onkeypress="return focusNext(this.form, 'name2', event)">

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint