473,396 Members | 1,764 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,396 software developers and data experts.

get the id of each enabled element in a form?

I have a form that has 4 <INPUT> elements in it each with a unique id. The page loads with the <INPUT> id = 1 with focus. If a tab is done immediately without entering anything in this INPUT text box then there are no other elements in the form enabled. Hence the TAB sends focus to the address bar. But if something is typed in for <INPUT> text box id = 1 then the second element which is a <INPUT> text box is enabled. Hence the TAB from the first <INPUT> after some information is entered ought to go to the second <INPUT> text box id = 2. The remaining elements are not enabled yet. Some information needs to be added to the second <INPUT> text box id = 2. But if not TAB again will send to address bar.

This is a description of the trouble I am having as I TAB through FORM elements where some of the elements can be disabled. But I need to know the next enabled element from the currently enabled element that a TAB is going to go to. Is this too complicated? Can it be done with JavaScript? Thanks.

--
George Hester
__________________________________
Jul 20 '05 #1
4 6912
In article <P1******************@twister.nyroc.rr.com>, "George Hester"
<he********@hotmail.com> writes:

<snip description>
This is a description of the trouble I am having as I TAB through FORM
elements where some of the elements can be disabled. But I need to know
the next enabled element from the currently enabled element that a TAB
is going to go to. Is this too complicated? Can it be done with
JavaScript? Thanks.


The simplest way is to tell it whats next, explicitly. Makes maintenance a pain
at times though.

setFocus function semi-solves your address bar problem. If the last field that
blurred has a length of 0, then it sets focus to the first form element (where
you said you wanted it to go instead of the address bar).

function setFocus(whatBlurred){
if (document.forms["myForm"].elements[whatBlurred].value.length == 0)
{
document.forms["myForm"].elements[0].focus();
}
}

function hasChanged(whatChanged,nextElement){
if (document.forms["myForm"].elements[whatChanged].value.length > 0)
{
document.forms["myForm"].elements[nextElement].disabled=false;
document.forms["myForm"].elements[nextElement].focus();
}
}
<form name="myForm" action="">
<input type="text" onBlur="setFocus(this.name)"
onChange="hasChanged(this.name,'input2')" name="input1">
<input type="text" onBlur="setFocus(this.name)"
onChange="hasChanged(this.name,'input3')" name="input2" disabled>
<input type="text" onBlur="setFocus(this.name)"
onChange="hasChanged(this.name,'input4')" name="input3" disabled>
<input type="text" onBlur="setFocus(this.name)"
onChange="hasChanged(this.name,'input1')" name="input4" disabled>
</form>

HTH

P.S. OT but why do I see the 3D's in your post? I removed them manually, but
its a pain to fix it :(
--
Randy
Jul 20 '05 #2
"P.S. OT but why do I see the 3D's in your post? I removed them manually, but its a pain to fix it"

It's because I use Quoted Priintable as th encoding. This newsgroup is the only one I post in where this issue causes such consternation. I use Outlook Express as my newsreader. And using that I cannot set the encoding specific to the newsgroup I post in. I have to use this encoding for the majority of my posts for in this way long URL links I post won't get sliced and therefore inoperable.

I apologize for this issue. But I just don't have the time to reset my global settings posting in a group I only periodically post to. Because then I'll be switching global settings left and right. That sucks. I also don't want a different newsreader. Hate to say it here but Outllok Express is actually the best one I have ever used for newsgroups. And I have tried others.

And yes I think you have helped. Take me a while to integrate it and figure out what's going on. Oh the joy of it.

--
George Hester
__________________________________
"HikksNotAtHome" <hi************@aol.com> wrote in message news:20***************************@mb-m29.aol.com...
In article <P1******************@twister.nyroc.rr.com>, "George Hester"
<he********@hotmail.com> writes:
--
Randy

Jul 20 '05 #3
In article <g3******************@twister.nyroc.rr.com>, "George Hester"
<he********@hotmail.com> writes:
"P.S. OT but why do I see the 3D's in your post? I removed them =
manually, but its a pain to fix it"

It's because I use Quoted Priintable as th encoding. This newsgroup is =
the only one I post in where this issue causes such consternation.


No consternation, and some useful information to me. I worte a simple script
that when I give it your post's, it auto-removes the 3D's for me :) I thought
it was OE5.5 related and was curious.
--
Randy
Jul 20 '05 #4
JRS: In article <20***************************@mb-m05.aol.com>, seen in
news:comp.lang.javascript, HikksNotAtHome <hi************@aol.com>
posted at Thu, 1 Jan 2004 22:49:40 :-
In article <g3******************@twister.nyroc.rr.com>, "George Hester"
<he********@hotmail.com> writes:
"P.S. OT but why do I see the 3D's in your post? I removed them =
manually, but its a pain to fix it"

It's because I use Quoted Priintable as th encoding. This newsgroup is =
the only one I post in where this issue causes such consternation.


No consternation, and some useful information to me. I worte a simple script
that when I give it your post's, it auto-removes the 3D's for me :) I thought
it was OE5.5 related and was curious.


Strictly, you should not do that; you should replace " = hex hex " by
the character corresponding to "hex hex h". In the case of =3D, that is
=, because the =3D is effectively an escaped =. But, IIRC, there is
also " = newline " which stands for "nothing at all, but the line is
long enough".

In some circles, instances of =A3 are common, and must be correctly
interpreted to avoid financial confusion.

DEMIME.(PAS EXE ZIP), /via/ sig line 3, run at a DOS prompt, should
remove that encoding from a saved copy of the article; since I routinely
don't accept GH's articles, I cannot test the case now.

No doubt the algorithm could be translated into javascript and applied
to the contents of a textarea.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>.
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Hill | last post by:
I have this large form with over 150 elements. I need to do some formatting of the data in some of the fields. I do this based on the name of the fields, i.e the field names would be cost1,cost2,...
2
by: David Pautler | last post by:
I'm creating a web-based authoring tool where one form encompasses several sections for editing. I'd like each section to have its own reset button, so that use of that button affects only that...
5
by: hiroshi ochi | last post by:
Hello, Using MSIE 6.0 and above, with javascript is it possible to display an individual tooltip for each item in a listbox? I need this functionality to show the listitems that are longer...
25
by: Ryan Stewart | last post by:
I'm working on a project to collect web application usage statistics. What are the recommended ways of detecting whether a browser is JavaScript enabled and/or capable? Obviously I can write a...
13
by: Alex Molochnikov | last post by:
Is there any way to find out programmatically if Javascript is supported/enabled in a browser? By "programmatically" I mean on the Java servlet side. TIA Alex Molochnikov Gestalt Corporation
5
by: Dani | last post by:
Hello everybody, I have some code that disables form elements on body load, but I notice when I hit the "back" button, I need to re-enable the form elements (that is done by clicking on a radial...
4
by: Gill Smith | last post by:
After setting the web control text box enable property to FALSE makes the control to loose the data between round trip. I am making sure that the property - EnableViewState = TRUE. Same code...
2
by: crjunk | last post by:
I'm trying to write a piece of code that will programatically save a record automatically without me having to add a new ' Row.Item("ADD1") = txtAdd1.Text.Trim.ToUpper ' type command each time I...
12
by: Anic297 | last post by:
Hi, This is certainly a simple question, but I'm a newbie in JavaScript. Is there a way to know if JavaScript is enabled? My php script uses JavasSript to do something. If JavaScript is not...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.