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

How can I pass trough all objects of a form, if some of them are contained in divs?

Hi!

I'm trying to pass trough all the objects of a form but I have some text
inputs in a DIV and I have many DIVs like this on my form.

I'm doing something like:

for (i = 0; i < document.forms(0).item.length; i++) {
dosomethingwith(document.forms(0).item(i));
}

but document.forms(0).item.length are the objects that are outside the
DIVs...

How can I pass trough all the objects of a form if some of them are
contained in divs?

Thanks a Lot!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
1 4144
Andrés Giraldo <an************@yahoo.com> writes:
I'm trying to pass trough all the objects of a form but I have some text
inputs in a DIV and I have many DIVs like this on my form.
What, exactly, do you mean by "all the objects of a form"?

If you only want to access the actual form controls (input, select,
textarea elements), then what you do is close to correct:

for (var i=0;i<document.forms[0].elements.length; i++) {
dosomethingwith(document.forms[0].elements[i]);
}

Use square brackets! Both forms and elements are collections, not
functions.
for (i = 0; i < document.forms(0).item.length; i++) {
dosomethingwith(document.forms(0).item(i));
This makes a lot of assumptions.

document.forms is a collection. It has a method called "item" that you can use to access the parts of the collection, or you can use square bracket notation.
document.forms.item(0) or document.forms[0]

However, IE shares the same object for both the forms collection and the
item function ("document.forms == document.forms.item" is true), so you
can get away with writing "document.forms(0)". Most other browsers wouldn't
accept that.

Likewise, in IE, for a form,
form == form.elements and form == form.elements.item

but document.forms(0).item.length are the objects that are outside the
DIVs...
Huh?
The above code iterates through all form controls, and nothing else.
The div's have no influence on this at all.
How can I pass trough all the objects of a form if some of them are
contained in divs?


Div's make no difference (unless you are using Netscape 4 and
positioned divs, which it interprets as layers and therefore separate
documents).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

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

Similar topics

4
by: Gerhard Pretorius | last post by:
ON Win 2003 IIS6, Since yesterday, (12 Aug 2003) for some strange reason, (after installing WindowsServer2003-KB823980-x86-ENU.exe) I cannot pass the Request object to to VB COM DLL. I have...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
5
by: Seeker | last post by:
Newbie question here... I have a form with some radio buttons. To verify that at least one of the buttons was chosen I use the following code ("f" is my form object) : var btnChosen; for...
2
by: bebelino | last post by:
Hello, this should be an easy one, but I've had always troubles with it. How to pass trough a querydef-variable, form-variable and so on from a function to the caller-routine? Is there a simply...
2
by: Mountain Bikn' Guy | last post by:
It is known that one cannot pass arguments as ref or out in a marshal-by-reference class. My problem is that I have a C DLL (and C# wrapper) that I need to isolate in an AppDomain and then I need...
5
by: equip200 | last post by:
i would like some assistance on how to pass data or string from one vb program to another c# program. can this be done with vbscript code to send data to the c# program? Thanks
38
by: Radi Radichev | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines...
5
by: Rob | last post by:
I have a control (Button) on a Parent form which opens a Windows form... all I want to do is pass a value from the child form back to the parent... it should be so simple... i.e....
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.