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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:19:23+00:00 2026-05-11T04:19:23+00:00

I have a form with thousands of checkboxes, and when one is checked, I

  • 0

I have a form with thousands of checkboxes, and when one is checked, I want to check all the boxes below it. This works:

<html> <body> <form name='myform'> <input type='checkbox' name='box1' onClick='redrawboxes(this);'>1<br> <input type='checkbox' name='box2' onClick='redrawboxes(this);'>2<br> ... </form> </body> </html> <script> function redrawboxes(obj){       //check all boxes below      var foundit=false;     for (e=0; e<document.myform.elements.length; e++){         if (foundit==false){ //search for checked obj             if(obj == document.myform.elements[e]){                  foundit=true;                }         }else{ //continuing below checked box             if(obj.checked){ //are we checking or unchecking                     document.myform.elements[e].checked = true;             }else{                     document.myform.elements[e].checked = false;             }         }     } } </script> 

but for more than a few thousand boxes, IE is unacceptably slow. (Firefox works fine.) Is there a better way to find the original box besides iterating through the whole list?

  • 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. 2026-05-11T04:19:24+00:00Added an answer on May 11, 2026 at 4:19 am

    Both of the jQuery suggestions are pretty good. For DOM wrangling like this, you’re really better off using a good library.

    And the comment about the dubious wisdom of putting thousands of checkboxes on a form is pretty good as well…

    But, on the off-chance that you do have a good reason for doing this, and you can’t use jQuery or similar, here’s a fast, straight JS method:

    function redrawboxes(obj) {       //check all boxes below          var next = obj;     while ( (next = next.nextSibling) )     {       if ( next.nodeName.toLowerCase() == 'input'          && next.type.toLowerCase() == 'checkbox' )         next.checked = obj.checked;     } } 

    tested in FF3, FF3.1, IE6, Chrome 1, Chromium 2

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

Sidebar

Related Questions

I have form with few buttons and I want to know what button is
I have form in my page, I am using ajax.beginform(). Inside this form I
I have form with multiple input type=radio with text next to them. I want
I have form like this: <div class=satu> <input type='text' size='1' maxlength='1' name='score[1][]' id='score[1][]'> </div>
I have form like this : <div id='add_field' class='locbutton'><a href='#' title='Add'>Add</a></div> <div id='remove_field' class='locbutton2'><a
I have form and I want to send values from it with ajax to
i have form with one selectbox ( collection_select ) for references column. What is
I have Form responsible for logging all neccessary informations from all thread into its
I have form with few text boxes which goes through validation (both server and
i have c# windows form when it opens it load thousands of record to

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.