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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:38:06+00:00 2026-05-26T18:38:06+00:00

I have a select all button on this page that works on other browsers

  • 0

I have a select all button on this page that works on other browsers but not IE8, can anyone see the problem but looking at my source?

UPDATE:

This is my code:

<td valign="middle" align="center"><input type="checkbox" name="products-quote[]" value="<?php echo $product_option['id']; ?>" /></td>
<td valign="middle" align="center"><input type="checkbox" name="products-sample[]" value="<?php echo $product_option['id']; ?>" /></td>

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

    <tr>
    <td valign="middle" align="center"><input type="checkbox" onClick="toggle(this)" name="products-quote[]" value="0" /></td>
    <td valign="middle" align="center"><input type="checkbox" onClick="toggle(this)" name="products-sample[]" value="0" /></td>
    <td><p><b>Select all</b></p></td>
    </tr>
  • 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-26T18:38:07+00:00Added an answer on May 26, 2026 at 6:38 pm

    You have made the following mistakes:

    1. Your markup fragment, if the PHP sections are ignored, is not Valid → W3C Markup Validator
    2. You have not declared checkboxes a (local) variable with the var keyword, which is error-prone.
    3. You have not made use of the backwards-compatible live collections for forms and form controls standardized by W3C DOM Level 2 HTML.
    4. You have attempted to iterate over the properties of an object implementing the NodeList interface of W3C DOM Level 2+ Core with a for–in statement. for–in iterates over enumerable properties of an object, but the properties of such host objects do not need to be enumerable. In fact, whether their properties with numeric name (which you were after) are enumerable, and whether their properties with non-numeric name are enumerable(!), depends on the DOM implementation. That accounts for the differences between browsers. Always use a (C-style) for statement there.

    Change to:

    <script type="text/javascript">
      function toggleAll(source)
      {
        var checked = source.checked;
        var checkboxes = source.form.elements[source.name];
    
        for (var i = checkboxes.length; i--;)
        {
          var checkbox = checkboxes[i];
          if (checkbox != source)
          {
            checkbox.checked = checked;
          }
        }
      }
    </script>
    
    …
    
    <form …>
      <table …>
    <?php
      foreach (… as $product_option)
      {
        /* DRY */
        $id = $product_option['id'];
    ?>
        <tr>
          <td><input type="checkbox" name="products-quote[]"
                     value="<?php echo $id; ?>"></td>
          <td><input type="checkbox" name="products-sample[]"
                     value="<?php echo $id; ?>"></td>
        </tr>
    <?php
      }
    ?>
        <tr>
          <td><input type="checkbox" name="products-quote[]" value="0"
                     onclick="toggleAll(this)"></td>
          <td><input type="checkbox" name="products-sample[]" value="0"
                     onclick="toggleAll(this)"></td>
          <td>Select all</td>
        </tr>
      </table>
    </form>
    

    Untested in this case, but generally proved. I have removed the presentational attributes and elements so that you can see the solution more clearly. You should replace those with CSS-based formatting.

    You might also want to consider giving the toggle checkboxes different names (so that you do not have to exclude them in the client-side iteration and server-side processing), and passing the checkbox group name as a second, string argument to toggle(…).

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

Sidebar

Related Questions

I have jQuery to select all font elements that are children of the element
I would like to select all elements that have certain attribute or don't have
I want to select all categories from a webservice. The webservice does not have
I have a DATETIME field. I would like to select all the records that
Suppose I have a datetime column in MySQL. How do I select all that
Dear all, I have a select query that currently produces the following results: DoctorName
On my main page I have a sort of side panel that can be
i have this simple code to load data from other php page using get
Suppose I have a column called fruits I want to select all of the
I have two table emptable1(empid,status) emptable2(empid,week) i want to select all the empid whose

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.