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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:20:38+00:00 2026-05-14T00:20:38+00:00

I want to fill an array in javascript that takes all the values out

  • 0

I want to fill an array in javascript that takes all the values out of different selectboxes with the same name

so for example if i have a html like this:

<select name="selectbox[]">
<option value="value1">text1</option>
<option value="value2">text2</option>
</select>

<select name="selectbox[]">
<option value="value1">text1</option>
<option value="value2">text2</option>
</select>

I have to get the selected values of both selectboxes and put it in an array.

what i did:

 $("input[name=selectbox\\[\\]]").map(function(){return $(this).val();});

does not work.

A similar example wich does work for textboxes:

$("input[name=textbox\\[\\]]").map(function(){return this.value;});

Thanks for your help!

  • 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-14T00:20:38+00:00Added an answer on May 14, 2026 at 12:20 am

    Perhaps because its a select and not an input ??

    var $select = $("<select multiple='multiple' />");
    for (var x=0; x<3; x++) {
      $select.append("<option value='"+x+"' selected='selected'>"+x+"</option>");
    }
    console.log($select.val());
    //  ["0", "1", "2"]
    console.log($select.map(function() { return $(this).val() }));
    //  jQuery("0", "1", "2")
    
    // create a second select:
    $select = $select.clone(true).andSelf();
    console.log($select.map(function() { return $(this).val() }));
    //  jQuery("0", "1", "2", "0", "1", "2")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to fill a ListView without an array of all the same things.
I want to fill all cells with the same control. What I have now
I have a three dimensional array which I want to fill in with values
I have an ImageButton that I want to fill its parent RelativeLayout container for
i want to fill the data of the charts from values i have in
I want to fill an array with int values which are extracted from a
I have an array $fields: Array ( [NAME] => M'y Na'me ) I want
I have an array of values that I would like to run through htmlspecialchars
I have the following Javascript function that should return an array of groups that
Actually I want to populate an array to fill up my table view, but

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.