Solved

Who to unselect all checkboxes

Posted on 2004-10-19
8
204 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:MMsabry
ID: 12348185
Nope did not work!
0
 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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