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

  • Home
  • SEARCH
  • 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 7750609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:20:06+00:00 2026-06-01T11:20:06+00:00

I have 11 checkboxes in my HTML form and already have a section in

  • 0

I have 11 checkboxes in my HTML form and already have a section in my onclick function to determine how many of them were checked, but I would like to be able to tell which of the checkboxes were checked, and possibly just add whichever checkboxes were checked to an arraylist by id/value etc.

EDIT: (Fixed code..?)

var formobj = document.forms[0];
    var ingNum = 0;
    checked = [];
    for (var j = 0; j < formobj.elements.length; j++) {
        if (formobj.elements[j].type == "checkbox" && formobj.elements[j].checked) {
                ingNum++;
                 checked.push(formobj.elements[j].value);
        }
    } 
  • 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-01T11:20:08+00:00Added an answer on June 1, 2026 at 11:20 am

    If you want to convert the ones checked to an array of their value attributes (if id attribute, swap value with id), you could use…

    var inputs = document.getElementById('your-form').getElementsByTagName('input'),
        checked = [];
    
    for (var i = 0, length = inputs.length; i < length; i++) {
        if (inputs[i].type == 'checkbox' && inputs[i].checked) {
            checked.push(inputs[i].value);
        }
    }
    

    That will work on any of the older IEs you may care about.

    If you have the luxury of only supporting newer browsers, you could use…

    var checked = [].slice.call(document
                   .querySelectorAll('#your-form input[type="checkbox"]'))
                   .filter(function(checkbox) {
                             return checkbox.checked;
                   })
                   .map(function(checkbox) {
                            return checkbox.value;
                   });
    

    If you were using a library such as jQuery, it’s even simpler…

    var checked = $('#your-form :checkbox:checked')
                  .map(function() {
                          return this.value;  
                   })
                  .get();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html-form with checkboxes. It is required that has been checked by
I have a HTML form containing checkboxes in the form of .. <input type=checkbox
I have a simple form that I would like to validate on form submission.
I have an array of checkboxes in a complex dynamic-html form. Whenever a user
I have multiple dynamic checkboxes. I would like to find out what checkbox was
I have a form with thousands of checkboxes, and when one is checked, I
I would like to get the updated DOM html string for the form elements
I have a HTML form that contains text fields, checkboxes, radiobuttons and a submit
If I have a html form like the following: <form name=statusForm action=post.php method=post enctype=multipart/form-data>
I have a HTML form and inside it I have a bunch of checkboxes.

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.