[thelist] form array, getting length of type of control

Cymbala, Greg Greg.Cymbala at Den.Galileo.com
Mon Sep 16 16:22:01 CDT 2002

Try this:

for (var i = 0; i < document.myForm.elements.length; i++)
  if (ddocument.myForm.elements[i].type == "checkbox")
    document.writeln(document.myForm.elements[i].name + " is a checkbox.");

-----Original Message-----
From: Tom Dell'Aringa [mailto:pixelmech at yahoo.com]
Sent: Monday, September 16, 2002 3:03 PM
To: thelist at lists.evolt.org
Subject: [thelist] form array, getting length of type of control

I'm trying to basically check or uncheck all the checkboxes in a form. I
want to use the elements array to find the length of how many there are so I
can iterate through them.

I cant' quite find the syntax. Danny Goodman says you can use the type to
loop through all elements in a form, but he doesn't provide an example
(strangely enough).

I was trying something like this

var length = myForm.elements["checkbox"].length;

but that is not correct. Can someone point me in the right direction?


var me = tom.pixelmech.webDeveloper();

The information in this electronic mail message is sender's business
Confidential and may be legally privileged.  It is intended solely for the
addressee(s).  Access to this Internet electronic mail message by anyone
else is unauthorized.  If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be taken
in reliance on it is prohibited and may be unlawful.
The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message and
its attachments could have been infected during  transmission. By reading
the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. Galileo International is not liable for any loss or damage
arising in any way from this message or its attachments.

More information about the thelist mailing list