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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:43:03+00:00 2026-06-14T14:43:03+00:00

I have read many other question on SO regarding selecting all checkboxes, but couldn’t

  • 0

I have read many other question on SO regarding selecting all checkboxes, but couldn’t find one that says how to trigger other checkboxes actions.

I have a main checkbox, when this checkbox is selected all other checkboxes are selected as well.
The thing is, other checkboxes have to perform their own action e.g disable text fields .etc if they are checked/unchecked. I achieved this by adding onclick to each checkbox. So how to call each checkbox onclick (or make each checkbox to perform their action) if the main checkbox is selected?

After reading about this I have made the following:

      // main checkbox functin that checks/unchecks other checkboxes. 

  function toggleAllCheckBoxes(source , operationType) {
                checkboxes = document.getElementsByName("checkBox" + operationType);
                for each(var checkbox in checkboxes)
                checkbox.checked = source.checked;
               // checkbox.addEventListener('click', true); // this is wrong.
            }


  //this will toggle text fields enabled/disabled
 function toggleDisable(oldTable, newTable , checkBox)
    {
        if( document.getElementById(newTable) !=null)// in case to toggle only old table
        {
            document.getElementById(newTable).disabled = checkBox.checked;
        }

        document.getElementById(oldTable).disabled = checkBox.checked;
    }

main checkbox:

All<input type="checkbox" onClick="toggleAllCheckBoxes(this , '<?=$operationType?>')"/> 

Other checkboxes

  X<input name="checkbox" id="checkbox" onclick="toggleDisable('<?= $originalTableId?>' , '<?= $backupTableId?>' , this )" type="checkbox" /> 

So far this works fine, except, text fields are not being enabled/disabled if main checkbox is selected. Although single checkboxes are able to do that.

Thanks.

  • 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-06-14T14:43:04+00:00Added an answer on June 14, 2026 at 2:43 pm

    I see two issues:

    1. There is no for each operator in JavaScript. You’ll need to use a
      normal for loop here.
    2. You don’t want to set the checked attribute
      for the checkbox because, as you’ve seen, that will bypass all event
      handlers. Instead, call click() on the checkbox and it will be
      checked (or unchecked) and all event handlers will be called.

    That will end up looking like this in toggleAllCheckBoxes:

    for(var i = 0; i < checkboxes.length; i++)
        checkboxes[i].click();
    

    Here’s a Fiddle to try this code out on: http://jsfiddle.net/z4Ltc/

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

Sidebar

Related Questions

I read many question about that and tutorials, but the only one executed, and
I apologize if this question is a duplicate. I have read many other mysqli
I have read many answers regarding this still i am getting confused if i
I have read many question about improving the performance of C++ and C code
I have read many questions about Android, J2ME and RecordStore , but I still
I have read many questions about the facebook login but until not I didnt
I have read so many times, here and everywhere on the net, that mutexes
OK I have read many posts regarding Dual Licensing using MIT and GPL licenses.
I'm using Delphi XE2 with FireMonkey. I have read many other questions about MD5
I have looked through many tutorials, as well as other question here on stack

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.