473,889 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Next form element

I'm trying to make it so that if the user sets focus to a form element
(text), it automatically sets focus to the very next form element. This
will, in effect, prevent the user from modifying the value. I know I can do
this by setting the form element to 'readonly' but that's not possible as
I'll need to modify that value elsewhere in my JS. Anyway...

I know I can do something like this:

document.forms[1].elements[4].focus().

Only problem for me with the above method is that I'm generating my form
dynamically so I won't know a) which element number the current field is and
b) which, if any, is the next element. I've tried setting up an event
handler so:

OnFocus='this.n extSibling.focu s();'

but that doesn't work. Apparently, I can't use nextSibling when working
with a form element. So I'm wondering how I can do what I'm needing to do?

Any help would be greatly appreciated!

thnx,
Chris
Jan 30 '06
15 2852
Thomas 'PointedEars' Lahn wrote on 02 feb 2006 in comp.lang.javas cript:
If I were to put a button in a form without type="button",
and it was not the submit button, some browsers


All widely distributed browsers except IEeek do.


I did not know hat.

But then, I personally always use <button> OUTSIDE a <form>,
and <input type= submit/reset INSIDE.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 2 '06 #11
JRS: In article <-P************** ******@comcast. com>, dated Wed, 1 Feb
2006 16:00:06 remote, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
Are there other special cases of <input type=... > that are widely
implemented?


Such as what?


If I knew what, I would not need to ask.

To explain to you in more detail :

In HTML, within <input > one can put type="..." and get an
input control of the type indicated by what is where I have put three
dots. It now seems to be established that <input type=button and
<input type="button" can be replaced by the simpler <button .

Examples : type=text type=radio type=password type=checkbox

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 2 '06 #12
Dr John Stockton wrote on 02 feb 2006 in comp.lang.javas cript:
It now seems to be established that <input type=button and
<input type="button" can be replaced by the simpler <button .


<button onclick='..'>Pr ess</button>

equals

<input type='button' onclick='..' value='Press'>

.... well sort of, I hope.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 2 '06 #13
"Evertjan." <ex************ **@interxnl.net > writes:
<button onclick='..'>Pr ess</button>

equals

<input type='button' onclick='..' value='Press'>

... well sort of, I hope.


Actually it equals
<input type="submit" onclick="..">Pr ess</button>
except that the rendering might be a little different too.

The button element has a type attribute taking one of the three
values: "button", "submit" and "reset", with "submit" being the
default. They work the same as the input elements with the same
type attribute.

The content of a button element can be arbitrary inline HTML. That
means that it might have a text baseline different from the
surrounding text (in some browsers it does for sure, can't remember
which).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 2 '06 #14
Lasse Reichstein Nielsen wrote on 02 feb 2006 in comp.lang.javas cript:
The content of a button element can be arbitrary inline HTML.
Which I think a definite improvement over <input button=''..:

<button>
Please press <span style='color:re d;'>here</span> now!
</button>
That
means that it might have a text baseline different from the
surrounding text (in some browsers it does for sure, can't remember
which).


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 2 '06 #15
Dr John Stockton said the following on 2/2/2006 7:10 AM:
JRS: In article <-P************** ******@comcast. com>, dated Wed, 1 Feb
2006 16:00:06 remote, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
Are there other special cases of <input type=... > that are widely
implemented? Such as what?


If I knew what, I would not need to ask.


Fair enough.

To explain to you in more detail :

In HTML, within <input > one can put type="..." and get an
input control of the type indicated by what is where I have put three
dots. It now seems to be established that <input type=button and
<input type="button" can be replaced by the simpler <button .

Examples : type=text type=radio type=password type=checkbox


No, only <button> has managed to mutate from <input type="button">.

One thing I have never understood, and probably never will, is why
<button> defaults to a submit button. <button type="button"> Seems
overkill. Leave it a button by default, same as input is text by
default. If you want something else then you give it the type.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 3 '06 #16

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

Similar topics

12
2479
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" HTML----------- Form is ----> <form action="thanks.php" method="post" name="contact_form" id="contact_form"> Name -------> <input type="text" name="name" id="name" size="25"> Button sends code -----> <input type="button" value="Submit Form"
7
12015
by: mcanedo | last post by:
Hi: I have several text elements in a form. Some of they are filled by the user, and then some are automatically filled based on the user input. Therefore I do not want the user to be able to write on the autofilled text elements. I have come to the idea of give those elements the event onFocus=functiontoMovetoNextElement() Then my question is how can I do that using the elements array?
1
5341
by: john woo | last post by:
Hi I'm not good at JS, but want to get more about it. I want to use a JSP (the java code just used to get date, the rest are html and javascript), to display a table. the requirement is the all rows in even number in light-blue, rows in odd number in light gray, when a mouse clicks on a row, this row gets highlighted and in yellow, and it keeps highlighted
2
1759
by: Deniz Bahar | last post by:
Hi, I'm working with a single linked list and want to delete elements by searching through the list (starting form the HEAD) then finding the element, then doing the following: NewElement = CurrentElement->next; CurrentElement->next = NewElement->next->next; free(NewElement);
13
14741
by: Joseph Garvin | last post by:
When I first came to Python I did a lot of C style loops like this: for i in range(len(myarray)): print myarray Obviously the more pythonic way is: for i in my array: print i
2
1692
by: zek2005 | last post by:
Hi!!! I've made a form with a 'select' statement through a echo('<select name="res">'); echo('<option selected value=""> Select option</option>");'); while($row = mysql_fetch_array($resumen)) { echo('<option value="' .$row. '">' ..strtoupper($row). '</option>');
2
55471
by: yawnmoth | last post by:
Say I have two input elements and that I wanted to make it so that when the first ones input was what it should be, the focus would automatically be shifted to the next input element. ie. something like... <input onkeyup="if (this.value.length == this.maxlength) document.forms.elements.focus()" value="whatever" maxvalue="x" type="text" /> <input value="whatever" maxvalue="x" type="text" />
2
3428
dlite922
by: dlite922 | last post by:
Before traversing my code, here's what my goal is and what this function does: I have a table of fields that dynamically grows as the user enters information. A minimum of 3 rows must always exist. (read the psedo code and comment if you need to know what it does) disregard the debugging , commented alerts. What i'm trying to do is without passing the ID or field that called this function, set the focus to the next element. what's...
10
4627
by: removeps-groups | last post by:
How to display table and select next to each other? <html> <body> <table border=1 style="display:inline-table"> <tr><td>Hello1</td></tr> <tr><td>Hello2</td></tr> <tr><td>Hello3</td></tr> <tr><td>Hello4</td></tr> <tr><td>Hello5</td></tr>
0
9961
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9802
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11186
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10887
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5825
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.