473,569 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

form's field number

abs
Input field of the form. How to check which number this field has ? I mean
the order number, like variable elementNumber in
document.forms[formnumber].elements[elementNumber] ? Is it possible to check
without looping and comparing some attributes in every loop ?

Best regards,
ABS
Jul 23 '05 #1
11 3113
abs wrote:
Input field of the form. How to check which number this field has ? I mean the order number, like variable elementNumber in
document.forms[formnumber].elements[elementNumber] ? Is it possible to check without looping and comparing some attributes in every loop ?

Best regards,
ABS


Why do you need this? Just curious. The only way afaik to do it without
run-time looping is to use a script onload that sets an index property
on each element:

window.onload = function()
{
var f, els, el, i = 0, j;
while (f = document.forms[i++])
{
els = f.elements;
j = 0;
while (el = els[j])
el.index = j++;
}
}

Then access as elementObj.inde x.

Jul 23 '05 #2
abs
RobB wrote:
Why do you need this? Just curious.


Because I can't use id and I need to identify the field.

Thank you for your response.

Regards,
ABS
Jul 23 '05 #3
abs
RobB wrote:
The only way afaik to do it
without run-time looping is to use a script onload that sets an index
property on each element:


One more question. maybe you know hot to get the element having specific
index ? Something like getElementByInd ex() ?

ABS
Jul 23 '05 #4
abs wrote:
RobB wrote:
The only way afaik to do it
without run-time looping is to use a script onload that sets an index property on each element:
One more question. maybe you know hot to get the element having

specific index ? Something like getElementByInd ex() ?

ABS


Hmm...that's why I asked what you needed here. First you had the
element object & wanted its position in the elements[] collection. Now
you've got the position and want the object.

FormObj.element s[index];

There are other ways to obtain a valid object reference to a form field
(or any HTML element) that rely upon DOM - document structure - rather
than ids or names. It would help to know what you were trying to
accomplish.

cheers, Rob

Jul 23 '05 #5
abs
RobB wrote:
Hmm...that's why I asked what you needed here. First you had the
element object & wanted its position in the elements[] collection. Now
you've got the position and want the object.
That's how it is :) It may seem stupid but I really need this.
There are other ways to obtain a valid object reference to a form
field (or any HTML element) that rely upon DOM - document structure -
rather than ids or names.


OK, I invented something like that: I'll set the fields' indexes as in the
pattern:
field.index = numberOfForm_nu mberOfField
And than, when i'll need to acces the filed, I'll split its index and use
document.forms[numberOfForm].elements[numberOfField].
Hope it will work :)

Regards,
ABS
Jul 23 '05 #6
Lee
abs said:

RobB wrote:
Why do you need this? Just curious.


Because I can't use id and I need to identify the field.


Why not use the field's "name" attribute?

Jul 23 '05 #7
abs
Lee wrote:
Why not use the field's "name" attribute?


Because I've got a form with names like 'date[]', 'something[]', etc and
there might be a lot of fields with the same name. It's not my will, so it
has to be like that.

ABS
Jul 23 '05 #8
Lee
abs said:

Lee wrote:
Why not use the field's "name" attribute?


Because I've got a form with names like 'date[]', 'something[]', etc and
there might be a lot of fields with the same name. It's not my will, so it
has to be like that.


So why not use the field's "name" attribute?

document.forms[0].elements["date[]"].value

Jul 23 '05 #9
abs

Użytkownik "Lee" <RE************ **@cox.net> napisał w wiadomo¶ci
news:d4******** @drn.newsguy.co m...
So why not use the field's "name" attribute?
document.forms[0].elements["date[]"].value


As I wrote, the fields might have the same names, like:

<input type="text" name="myname[]">
<input type="text" name="myname[]">

Regards,
ABS
Jul 23 '05 #10

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

Similar topics

6
32686
by: Susan | last post by:
Is there any way to take one of the fields from the form and use that as your subject line.. right now I have a default subject line entered - but would rather have the subject be the information the user has typed into the field "store" current code: <!-- Start of FORM --> <form method="POST" action="mailto:abc@abc.com?subject=ABC...
36
11297
by: Martin Herrman | last post by:
Dear scripters, I am working on a HTML form in which a date must be entered of the form 'dd-mm-yyyy'. Now I'm looking for a script that, when the user switches to another form field, changes e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'. I have searched the net using google, but only found validators that show an error if an incorrect...
19
2131
by: cover | last post by:
Is there a restriction to the number of fields you can work with in a PHP to MySQL connection? I'd used as many as 15 quite a few times and now I have a form with 34 fields and can't seem to get the info inserted into the table even though I'm not getting any connection errors, etc. Since my method is identical, I'm wondering if there's...
3
5570
by: john | last post by:
I'm trying to refer to a form's field in a query like this strSQL = "SELECT Transactie.* INTO CatTemp" strSQL = strSQL & " FROM Transactie" strSQL = strSQL & " WHERE Transactie.Categorie1=!! ;" dBEngine(0)(0).Execute strSQL, dbFailOnError but I can't get it to work. I get the message that there are too less parameters.
1
2131
by: sjvandevoorde | last post by:
I need some help with a couple forms/test fields. Bare with me I have been out of the field for some time and only consider myself an intermediate user. The first one is a subfrom which lists records including Decrease and Increase field. I have two text fields which are suppose to total each of these fields. This subform is within another...
2
8298
by: John | last post by:
In my query I'm trying to reference to a numeric (autonumber) field of my form but I can't get it to work. Error message: "Datatypes don't match in the criterium expression." This is the particular line that doesn't work: strSQL = strSQL & "WHERE (((Contact.ID_contact)='" & Me.ID_contact] & "'));" When I replace '" & Me.ID_contact] & "'...
2
2575
by: tahseenm | last post by:
I would like to know the easy way to make my date field to pop up calendar to select my dates in a form date field. Thanks and let me know soon.
1
3629
by: popoypopoy | last post by:
How to create an email attachment for the user's biodata from the form file field using Persist.MailSender ?
0
7703
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...
0
7619
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...
0
7930
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. ...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
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...
0
5228
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...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
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
1
1229
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.