Solved

Who to unselect all checkboxes

Posted on 2004-10-19
8
203 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
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.

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IIS 8.5 2 51
whm high memory usage in processes 7 69
http to https 3 41
app server have enough resources... 2 23
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

17 Experts available now in Live!

Get 1:1 Help Now