Solved

JSF - Auto Tab To Next Field

Posted on 2008-10-02
4
2,062 Views
Last Modified: 2013-11-24
Hello:

How can I implement jumping to next field after user enters all the required number of characters?
The document.getElementById('FieldId') ALWAYS returns null!!.

I have code like this

<h:inputtext id "FieldText"  maxlenght = "5" ....... onkeyup ="AutoTabToNextField(this, 'NextField')" />
h:inputtext id = "NextField" ,,,, />

My javascript looks like:

AutoTabToNextField(F1, F2)
 {
  // This is the problem. No Matter what method I use to pass reference to F2,
 //  F2 is ALWAYS ALWAYS NULL or is not an OBJECT!!!

// F1 is passed correctly ... ALWAYS .. I think it is because of using "this"

  if (F1.value.length == F1.maxLength)
  {
    F2.focus();
  }
 }

Thanks,

<<< Ali >>>
0
Comment
Question by:MohammadAliQureshi
  • 2
  • 2
4 Comments
 
LVL 14

Assisted Solution

by:Farzad Akbarnejad
Farzad Akbarnejad earned 500 total points
ID: 22631127
Hi,
Instead of 'NextField' pass '[Form Name].NextField' (replace [Form Name] with name of form contains input control.

-FA
0
 

Accepted Solution

by:
MohammadAliQureshi earned 0 total points
ID: 22632376
Hello FarzadA:

I think I have tried that as well and it did not work. However, let me try one more time. I will update you with the results.

Thanks,

<<< Ali >>>
0
 

Author Comment

by:MohammadAliQureshi
ID: 22634440
Hello:

I found the solution. I had to call my JS function with refernce to nextField as 'formID:FieldID'. Yes it is colon. The way I figured it out was to look at the HTML source created by the JSP and look at what are the ids for different fields. Then, within the function, I get the reference to the field by using document.getElementById to set the focus.

Since FarzadA started my thinking process which led me to a solution, I will award him full points. Thanks for your help FarzadA.

thanks,

<<< Ali >>>
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 22639273
'formID:FieldID' is JSF naming. You can use forceId=true attribute in inputText tag to force JSF use you id.

<h:inputtext id="NextField" forceId="true" ....

Now you can use its id without pointing to 'formID:'

-FA
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
countHi challenge 25 124
countAbc challenge 9 60
strCount chalenge 3 82
what is the main difference between git clone and fetch ann pull and push commands 2 91
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

823 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