Solved

Who to unselect all checkboxes

Posted on 2004-10-19
8
202 Views
Last Modified: 2013-12-24
Hi, I would like to have button on a page (contains a table with each row has a checkbox) that deselect all checked boxes
thanks
0
Comment
Question by:MMsabry
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:kkhipple
ID: 12348033
try this...this code allows you to check and uncheck all checkboxes

<!--- place above checkbox--->
<SCRIPT>
function checkBoxes (form, check) {
var flagThis = false;
  for (var c = 0; c < form.elements.length; c++)
      flagThis = false;
      if (form.elements[c].type == 'checkbox')
        form.elements[c].checked = check;
        flagThis = true;
      if (flagThis)
        form.elements[c].checked = enabled;
}
</SCRIPT>


<!--- to check all checkboxes --->
<INPUT TYPe="CHECKBOX" NAME="applyToAll" ONCLICK="checkBoxes(this.form, this.checked)" VALUE="yes">




0
 

Author Comment

by:MMsabry
ID: 12348074
thank, but what do you mean by : <!--- place above checkbox--->, you meant place in the head of the page, right?
0
 
LVL 5

Expert Comment

by:kkhipple
ID: 12348098
yes that's whta i meant....

0
 

Author Comment

by:MMsabry
ID: 12348185
Nope did not work!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Accepted Solution

by:
kkhipple earned 100 total points
ID: 12348226
That's odd, well try this piece of code. As this works just fine in my browser. If you have SP2 for XP then allow blocked content.


<HTML>
<HEAD>
<TITLE>

</TITLE>
<STYLE>
</STYLE>
<SCRIPT>
function checkBoxes (form, check) {
  for (var c = 0; c < form.elements.length; c++)
    if (form.elements[c].type == 'checkbox')
      form.elements[c].checked = check;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName">
Check all
<INPUT TYPE="checkbox" NAME="checkAll"
       ONCLICK="checkBoxes(this.form, this.checked)"
>
<BR>
<UL>
<LI>
<INPUT TYPE="checkbox">
</LI>
<LI>
<INPUT TYPE="checkbox">
</LI>
<LI>
<INPUT TYPE="checkbox">
</LI>
<LI>
<INPUT TYPE="checkbox">
</LI>
<LI>
<INPUT TYPE="checkbox">
</LI>
<LI>
<INPUT TYPE="checkbox">
</LI>
</UL>
</FORM>
</BODY>
</HTML>
0
 

Author Comment

by:MMsabry
ID: 12348297
thanks, second code works fine, and nope I did not install SP2 yet, I'm in the middle of a project, not taking any risks.
now, this works fine to select all but to if i select a few and want to deselect them, i have to click your check box twice!
is there a way around this?
thanks
0
 
LVL 1

Expert Comment

by:hiranmaya
ID: 12354851
Try kkhipple code. And assign your points to him. That works.
0
 

Author Comment

by:MMsabry
ID: 12356740
hiranmaya, "YES, Sir"!!!!
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

18 Experts available now in Live!

Get 1:1 Help Now