By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

Dynamically determine current field element?

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
M Wells wrote:
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?
--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Jul 20 '05 #2

P: n/a
document.forms[0].length

M Wells a écrit:
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


Jul 20 '05 #3

P: n/a
On Tue, 03 Feb 2004 10:26:43 +0100, Bas Cost Budde <ba*@heuveltop.org>
wrote:
M Wells wrote:
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?


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
Jul 20 '05 #4

P: n/a
> 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?

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.