Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Who to unselect all checkboxes

Posted on 2004-10-19
8
Medium Priority
?
210 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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 

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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

609 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