Dynamically determine current field element?

M

M Wells

Hi All,

Is it possible to dynamically determine the current field element in a
form?

I ask because I have a 'tab' button on a form, and when a user clicks
on it I need to be able to shift the focus to the next field, and also
if the current field is the last field on the form, essentially to do
nothing.

Conceptually, I guess I'm trying to do something like:

function clicktab(){

variable = current.field.element.number;
if (variable < n) {
variable++;
document.forms[0].element[variable].focus;
}
}

In the above function, "n" would be the total number of fields in the
form.

I'd very much appreciate any assistance anyone can give!

Much warmth,

Murray
 
B

Bas Cost Budde

M said:
Hi All,

Is it possible to dynamically determine the current field element in a
form?

If you are willing to do some initializing, you can attach
onfocus-handlers to every field, that write their tabIndex to a global
variable. Then, on click of your tab button, you can increment the
global variable and set focus on that element.

Know how to proceed?
 
M

M Wells

If you are willing to do some initializing, you can attach
onfocus-handlers to every field, that write their tabIndex to a global
variable. Then, on click of your tab button, you can increment the
global variable and set focus on that element.

Know how to proceed?

Hiya,

What I'm wondering is if there's any way of retrieving the element
number of the field.

So, a way of knowing that document.forms[0].elements[5] currently has
the focus, as opposed to document.forms[0].elements[6] etc.

Much warmth,

Murray
 
B

Bas Cost Budde

What I'm wondering is if there's any way of retrieving the element
number of the field.

So, a way of knowing that document.forms[0].elements[5] currently has
the focus, as opposed to document.forms[0].elements[6] etc.

Without any action before? wishing "document.currentElement"?
I doubt it, I couldn't find anything pointing in that direction when I
searched. Can you put window.getSelection to use?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top