473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Dynamically determine current field element?

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
4 5473
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
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
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: user | last post by:
Hi, I'm writing a DBI for my company's database. I will have one class for each of the tables in the database. I would then like each class, once instantiated, to be able to read the field...
5
by: George Hester | last post by:
Say I have this in a web page: <center><a href="http://www.microsoft.com">www.microsoft.com</a></center> I can use CSS, the DOM and\or JavaScript to determine the width style.innerHTML.length...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
0
by: Diane Yocom | last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but... I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where...
2
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status)...
5
by: Mike Dee | last post by:
Is it possible to dynamically create a new form object (form1), then create a new form field object and add it form1, and then add form1 to the current document? I need to do all this in script...
1
by: vega80 | last post by:
Hi. I have a problem with assigning an onkeypress-function to dynamically created input-boxes.I want to put the content of an input-field into a tag-list when the user hits enter. This works...
7
by: Ron Goral | last post by:
Hello I am new to creating objects in javascript, so please no flames about my coding style. =) I am trying to create an object that will represent a "div" element as a menu. I have written...
5
by: phpCodeHead | last post by:
I am needing to determine how to go about validating that a field in my form contains only a positive integer. I know that this is fairly simple if the form contains only one element to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.