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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:22:53+00:00 2026-05-25T23:22:53+00:00

I have two columns of checkboxes with a select all checkbox at the bottom

  • 0

I have two columns of checkboxes with a select all checkbox at the bottom of each column. I want the first select all checkbox to check all in one column, and the second select all checkbox to tick all in the second column.

See the following example – http://www.dtrmedical.com/test-site/index.php?id=3&productid=118

The first select all checkbox works correctly (it ticks everything within the quote column). I can’t get the second one to work alongside it. It should just tick/untick all in the sample column.

Can anyone help please?

This is the product tick box:

<td valign="middle" align="center" style="background-color:#C3DCCD;"><input style="margin-top:5px;" type="checkbox" name="products-quote" value="echo $product_option['product_code']; ?>" /></td>
<td valign="middle" align="center" style="background-color:#D3C4DF;"><input style="margin-top:5px;" type="checkbox" name="products-sample" value="echo $product_option['product_code']; ?>" /></td>

This is the javascript to do the first select all:

<script language="JavaScript">
function toggle(source) {
  checkboxes = document.getElementsByName('products-quote');
  for(var i in checkboxes)
    checkboxes[i].checked = source.checked;
}
</script>

And these are the select all checkboxes:

    <td valign="middle" align="center" style="background-color:#efefef;"><input style="margin-top:5px;" type="checkbox" onClick="toggle(this)" name="products-quote" value="echo $product_option['product_code']; ?>" /></td>
<td valign="middle" align="center" style="background-color:#efefef;"><input style="margin-top:5px;" type="checkbox" name="products-sample" value="echo $product_option['product_code']; ?>" /></td>
  • 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-25T23:22:53+00:00Added an answer on May 25, 2026 at 11:22 pm

    OK, it looks like each of your “select all” checkboxes has the same name attribute as the rest of the checkboxes in its column, so a pretty minimal change to get it working is to use the function you’re already using with a minor change:

    function toggle(source) {
      //checkboxes = document.getElementsByName('products-quote');
      checkboxes = document.getElementsByName(source.name);
      for(var i in checkboxes)
        checkboxes[i].checked = source.checked;
    }
    

    Instead of getting the checkboxes with a hard-coded name get the ones with the same name as the clicked element. Then both of your “select all” checkboxes can say onClick="toggle(this)" to call the same function.

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

Sidebar

Related Questions

I have two data frames with two columns each. The first column is timestamps
i am using asp.net gridview in header i have two columns column select all
I have created an HTML table with two columns. I want the first column
I have two tables [Source: table1, Destination:table2] with 3 columns each (checkbox, value1, value2).
I have two columns one for id & other for checkboxes. i have taken
We have checkboxes in two columns (they denote the same category, but different subscription)
I have two columns, senderUserID and recieverUserID in Messages table. I select senderUserID and
I have two columns of numbers. Both are 1 to 5. I want to
I have some checkboxes dynamically created in C# codebehind. Let's say two columns. This
I have a JTable with four columns, the first one containing either a number

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.