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 6761665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:13:10+00:00 2026-05-26T14:13:10+00:00

Hi All First of all I don’t know Javascript, I got this script from

  • 0

Hi All First of all I don’t know Javascript, I got this script from the internet but can’t get it to work. If someone can please be so kind and assist me. I’m trying to create a “check all” & “uncheck all” button on my form for my checkboxes, if I click the button it does not select anything. Where am I going wrong?

<?php
session_start();
?>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--

<!-- Begin
function CheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}

function UnCheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
// End -->
</script>
</head>

And then the form:

$sql0 = "SELECT * FROM .....
$result0 = mysql_query($sql0);
echo "<form name='myform' action='...' method='post'>";
while($row0 = mysql_fetch_assoc($result0)) {
   $test_id=$row0['id'];
   $test_name=$row0['test_name'];

echo "  <table width=600px>";
echo "      <tr>";
echo "          <td width=30px><input name='question[$test_id][]' type='checkbox' value='1' /></td>";
echo "          <td width=580px align=left>$test_name</td>";
echo "      </tr>";
echo "  </table>";
}
echo "</P>";
echo "<input type='button' name='Check_All' value='Check All' onClick='CheckAll(document.myform.check_list)'>";
echo "<input type='button' name='Un_CheckAll' value='Uncheck All' onClick='UnCheckAll(document.myform.check_list)'>";
echo "</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-26T14:13:10+00:00Added an answer on May 26, 2026 at 2:13 pm

    I’d highly recommend using jQuery, it allows you to focus on the logic and not worry about cross browser issues you might run into.

    <script src='http://code.jquery.com/jquery-1.6.3.min.js' type='text/javascript'></script>
    <script>
    $(document).ready(function () {
       //check all
       $('input[name="Check_All"]').click(function () {
          //for all checkboxes where the name begins with "question", check them
          $('input[name^="question"]').attr('checked', true);
       });
    
       //uncheck all
       $('input[name="Un_CheckAll"]').click(function () {
          //for all checkboxes where the name begins with "question", uncheck them
          $('input[name^="question"]').attr('checked', false);
       });
    });
    </script>
    

    Here’s the breakdown…

    Select all buttons on the page where the name attribute is set to Check_all

    $('input[name="Check_All"]')
    

    When the found item(s) are clicked, execute the code in the function that is passed

    $('input[name="Check_All"]').click(function () {
        //javascript code here
    });
    

    for all checkboxes where the name begins with “question”, check them

    $('input[name^="question"]').attr('checked', true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all I don't know if this is the right approach. I want
First of all, I know about the command line parameter, but I don't want
First of all I don't know if it this question belongs here if not
First of all let's emphasize that syntax rules don't work alone, but they need
How do I select all but the first TDs? I don't know how many
Is it possible to display all but first row from a table in sql
First of all, I know how to build a Java application. But I have
I don't know how to do this with awk But my target is to
First of all, I don't think this question is a duplicate of Detect 64bit
First of all I'm using netbeans as my IDE and I don't know if

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.