?
Solved

Who to unselect all checkboxes

Posted on 2004-10-19
8
Medium Priority
?
209 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
[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
  • 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
Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

 

Author Comment

by:MMsabry
ID: 12348185
Nope did not work!
0
 
LVL 5

Accepted Solution

by:
kkhipple earned 400 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

770 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