?
Solved

onClick check all checkboxes

Posted on 1998-05-14
1
Medium Priority
?
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

Accepted Solution

by:
sybe earned 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

This article discusses how to create an extensible mechanism for linked drop downs.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

771 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