onClick check all checkboxes

Posted on 1998-05-14
Last Modified: 2008-02-01
How do I onclick of button, check all checkboxes on a form. (FYI form Name = sched)?
Question by:capoeira
1 Comment
LVL 28

Accepted Solution

sybe earned 50 total points
ID: 1278061
The code below works in NS3, haven't checked it with other browsers. You can't do it with a submit button, because this will submit the form. But in stead of the text between the <a href=...> and </a> you can use an image which looks like a button.

You can build in a check if a form element is a checkbox or not.
something like:
if (document.form1.element[i].type = "checkbox") {



function CheckThem() {
      i = 0;
      while (i < document.form1.length) {
            document.form1.elements[i].checked = true;
            i = i + 1


<form name="form1">
<input type="checkbox" name="a">
<input type="checkbox" name="b">
<input type="checkbox" name="c">
<input type="checkbox" name="d">
<input type="checkbox" name="e">
<input type="checkbox" name="f">
<input type="checkbox" name="g">
<input type="checkbox" name="h">
<input type="checkbox" name="i">
<a href="Javascript:CheckThem()">Check All Boxes</a>



Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maven not picking latest jar instead picking old jar from .m2 12 42
Coding for the first time 9 62
JS library vs Js framework 11 20
null, truthy, falsey confusion 25 28
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. …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

680 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