Solved

onClick check all checkboxes

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

Accepted Solution

by:
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") {

}

============

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

</script>

<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">
<P>
<a href="Javascript:CheckThem()">Check All Boxes</a>

</form>

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

707 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

14 Experts available now in Live!

Get 1:1 Help Now