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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:16:36+00:00 2026-05-13T14:16:36+00:00

I currently have a list of checkboxes all with the same ID which are

  • 0

I currently have a list of checkboxes all with the same ID which are hidden and I want to grab the list of the ones that are checked, is this possible? I am currently using this format:

selected_list = $("#ID").attr("checked", "true");

this however is only returning the top one when I read them into a variable with a loop like this:

list = '';
$(selected_list).each(
    function() {
          list += $(this).val() + " ";
    } 
);

alert(list);

Anyone know of a better way of doing this or why my version is only returning the first checkbox? 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-05-13T14:16:36+00:00Added an answer on May 13, 2026 at 2:16 pm

    You shouldn’t re-use ID values, they are supposed to be unique:

    $("#elementID:checked");
    

    Ideally, you should give them all the same class, or name, depending on how you want to use them. But you should never use the same ID over and over on a single page.

    <input type="checkbox" name="Apples"  class="fruit" />
    <input type="checkbox" name="Oranges" class="fruit" />
    

    We can select these various different ways. First, by class:

    $(".fruit:checked");
    

    Or simply by a vague checkbox call:

    $(":checkbox:checked");
    

    Or, in the case with radio buttons, if they all shared the same name value:

    $("[name='elements']:checked");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have this, which works nicely - it's an email signup list which
I currently have a script which allows me to output the list of files
How would I create a nested list, I currently have this public function getNav($cat,$subcat){
Currently I have the follow ps that reads a list of user names and
I have a list box and i am trying to get currently checked item
I have a viewmodel called ArticleAdmin that includes a list of checkboxes: public class
I have a list of items which I want the user to be able
I have a checkbox list for weekdays and I want to make sure that
I currently have a list of DateTimes stored as the timezone's UTC datetime. When
I currently have a list of things to update in the given mysqli query:

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.