Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6961553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:32:42+00:00 2026-05-27T15:32:42+00:00

The following code works fine when selecting all checkboxes, however it uses the the

  • 0

The following code works fine when selecting all checkboxes, however it uses the the input type of button. How could i change this into an anchor (eg. like a link) instead of an input type of button. This needs to update to UnCheck All once all are selected. I have tried using the innerHTML placing it within a DIV, however have not been successful. I would be grateful for any help like always.

Many thanks

<script language="JavaScript">
function Check(chk)
{
if(document.myform.Check_All.value=="Check All"){
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
document.myform.Check_All.value="UnCheck All";
}else{

for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
document.myform.Check_All.value="Check All";
}
}

// End -->
</script>
<form name="myform" action="checkboxes.asp" method="post">


<input type="checkbox" name="check_list" value="1">apple<br>
<input type="checkbox" name="check_list" value="2">banana<br>
<input type="checkbox" name="check_list" value="3">pear<br>

<input type="button" name="Check_All" value="Check All" onClick="Check(document.myform.check_list)"> 



</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:32:42+00:00Added an answer on May 27, 2026 at 3:32 pm

    I first thought up of a quick answer but then I noticed that this will suck pretty badly
    because it’s completely braindead if someone manually ticks the checkboxes.

    <form name="myform" action="checkboxes.asp" method="post">
    <input type="checkbox" name="check_list" value="1">apple<br>
    <input type="checkbox" name="check_list" value="2">banana<br>
    <input type="checkbox" name="check_list" value="3">pear<br>
    </form>
    
    <div id="checker">Check All</div>
    
    <script type ="text/javascript">
    //The toggle code for the div itself
    $("#checker").bind("click", function() {
        var toggleState = !! jQuery.data(this, "togglestate");
    
        $(document.myform.check_list).each(function() {
        this.checked = !toggleState;
        });
    
    
        $(this).text(toggleState ? "Check All" : "UnCheck All");
        jQuery.data(this, "togglestate", !toggleState);
    });
    
    //Keep track of manual ticking of the checkboxes
    //- if all checkboxes are ticked manually, change to uncheck all
    //- if all checkboxes are unticked manualy, change to check all
    
    $(document.myform).delegate("input[name=check_list]", "change", function() {
        var curState, prevState, fullStateChange = true;
    
        //Iterate through the checkboxes to see if all are unticked or if all are ticked
        $(document.myform.check_list).each(function() {
        curState = this.checked;
    
        if (prevState != null && prevState !== curState) {
            fullStateChange = false;
        }
    
        prevState = curState;
        });
    
        //Return as some were ticked and some were not
        if (!fullStateChange) {
        return;
        }
    
        $("#checker").data("togglestate", curState).text(!curState ? "Check All" : "UnCheck All");
    
    });
    
    //React to initial state of the checkbuttons
    $(document.myform.check_list).trigger( "change" );
    </script>
    

    Demo

    http://jsfiddle.net/rBaUM/2/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

following code work fine but 1 error $(document).ready( function() { $(#myCheckboxes input[type='checkbox']).change(function() { var
The following code works fine for Visual C++ 2008. However, when comes to Visual
I have the following code which works fine. However, I only want to return
Following code works fine in Firefox. In IE(8.0) button 2 does not work. $('<button
Just run into a tricky NSFetchedResultsController problem. The following code works fine in all
I have the following code in my controller. This works fine in Internet Explorer 9 and
The following code works fine in Delphi 7. However, in Delphi 2009 the form
The following code works fine: person = {:a=>:A, :b=>:B, :c=>:C} berson = {:a=>:A1, :b=>:B1,
The following code works fine #define open { #define close } #include<stdio.h> #define int
The following code works fine : std::map<int, int>& m = std::map<int, int>(); int i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.