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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:46:03+00:00 2026-05-12T15:46:03+00:00

Have a potentially infinite collection of drop downs, giving them all the same class,

  • 0

Have a potentially infinite collection of drop downs, giving them all the same class, need to be able to access, loop through, and collect the selected value on the option of all the drop downs regardless of how many there could be. The final form should be something like 5,6,7,6,4,2,3,4,3,4 as a comma delimited list of the selected values from all drop downs.

  • 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-12T15:46:03+00:00Added an answer on May 12, 2026 at 3:46 pm
    var ids = $("select.classname > option:selected").map(function(n, i) {
      return $(n).val();
    }).join(",");
    

    To explain what that’s doing:

    1. Firstly it selects all the selected options within the given drop downs (identified by “classname”);
    2. It passes every selected option to a callback function;
    3. That callback function returns the value of the selected option;
    4. Because you called map on the array of selected options, you’ve now got an array of values using the map() method;
    5. The join() function transforms that array into a comma delimited list.

    For example:

    <select class="classname">
      <option value="1">One</option>
      <option value="2" selected>Two</option>
      <option value="3" selected>Three</option>
    </select>
    <select class="classname">
      <option value="4">Four</option>
      <option value="5" selected>Five</option>
    </select>
    

    first uses $() to construct a jQuery object of the selected options (2, 3 and 5), maps the value attributes into an array of {2,3,5} and then joins them into a comma-delimited string "2,3,5".

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

Sidebar

Related Questions

Hi I am trying to return a collection which may potentially have null date
I have a Shape class containing potentially many vertices, and I was contemplating making
So I need to define the potential in python. I have infinite square well
Problem: a table of coordinate lat/lngs. Two rows can potentially have the same coordinate.
how could I efficiently do collection membership checks in Javascript? I have a potentially
I have potentially large files that need to be sorted by 1-n keys. Some
I have an application that can potentially have hundreds of memory mapped, i.e., mmap()
I have a table that potentially will have high number of inserts per second,
We have a folder where our app will be potentially reading, writing and creating/deleting
I have been learning the mapreduce algorithm and how it can potentially scale 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.