472,139 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 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 6783
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Michael Hill | last post: by
25 posts views Thread by Ryan Stewart | last post: by
13 posts views Thread by Alex Molochnikov | last post: by
12 posts views Thread by Anic297 | last post: by

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.