What is the checkbox array in the DOM?

Posted on 2004-08-16
Last Modified: 2011-10-03
I have a form with a couple of listboxes and a lot of checkboxes.  I am looking to make all of these checkboxes unchecked.

for (var i=0; i<document.form.checkbox.length; i++)
  document.form.checkbox[i].checked = false;

However, whenever I run this, I get an error that says that document.form.checkbox.length is null or not an object.

The only thing I can think of is that checkbox is not the array in the DOM that I am looking for.

What is the correct syntax for this?

BTW  The checkboxes are not the same name, nor can they be the same name.
Question by:light777
LVL 15

Expert Comment

Comment Utility
try this

for( intIndex = 0; intIndex < document.formname.length; intIndex++ )


   if( document.formname[ intIndex ].type  == "checkbox" )
      document.formname[ intIndex ].checked = false;


for( intIndex = 0; intIndex < document.all.length; intIndex++ )


     if( document.all( intIndex ).type == "checkbox" )
          document.all( intIndex )checked = false;

Accepted Solution

MrClean21 earned 125 total points
Comment Utility
Here's a technic to uncheck all checkboxes.

for (var c = 0; c < document.form.elements.length; c++)
   if (document.form.elements[c].type == 'checkbox')
      document.form.elements[c].checked = false;


Author Comment

Comment Utility
Thanks, that works perfectly

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (, typical array handling might look like this: (CODE) B…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now