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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:15:56+00:00 2026-06-06T20:15:56+00:00

I want to loop through the checkboxgroup ‘locationthemes’ and build a string with all

  • 0

I want to loop through the checkboxgroup ‘locationthemes’ and build a string with all selected values.
So when checkbox 2 and 4 are selected the result would be: “3,8”

<input type="checkbox" name="locationthemes" id="checkbox-1" value="2" class="custom" />
<label for="checkbox-1">Castle</label>
<input type="checkbox" name="locationthemes" id="checkbox-2" value="3" class="custom" />
<label for="checkbox-2">Barn</label>
<input type="checkbox" name="locationthemes" id="checkbox-3" value="5" class="custom" />
<label for="checkbox-3">Restaurant</label>
<input type="checkbox" name="locationthemes" id="checkbox-4" value="8" class="custom" />
<label for="checkbox-4">Bar</label>

I checked here: http://api.jquery.com/checked-selector/ but there’s no example how to select a checkboxgroup by its name.

How can I do this?

  • 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-06T20:15:58+00:00Added an answer on June 6, 2026 at 8:15 pm

    In jQuery just use an attribute selector like

    $('input[name="locationthemes"]:checked');
    

    to select all checked inputs with name “locationthemes”

    console.log($('input[name="locationthemes"]:checked').serialize());
    
    //or
    
    $('input[name="locationthemes"]:checked').each(function() {
       console.log(this.value);
    });
    

    Demo


    In VanillaJS

    [].forEach.call(document.querySelectorAll('input[name="locationthemes"]:checked'), function(cb) {
       console.log(cb.value); 
    });
    

    Demo


    In ES6/spread operator

    [...document.querySelectorAll('input[name="locationthemes"]:checked')]
       .forEach((cb) => console.log(cb.value));
    

    Demo

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

Sidebar

Related Questions

Suppose I have a vector<int> myvec and I want to loop through all of
I want to loop through a databale and change the values of a specific
I want to loop through a collection of objects and add them all to
I have the following code and i want to loop through all the fields
I want to loop through all the variables stored in the session. I checked
Suppose we want to loop through all the items in a dropdown list and
From inside a mvc (2) user control, I want to loop through all the
I want to loop through my Car class with reflection to remove all null
I want to loop through a xml file and display the values in text
I want to loop through the values of a particular column in datatable? can

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.