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

The Archive Base Latest Questions

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

I have the following form, and I am dynamically adding more dropdowns (exactly the

  • 0

I have the following form, and I am dynamically adding more dropdowns (exactly the same as these) if the user clicks on the link to add more items

<div class="dynamic-sale">
      <select name="sizes[]" id="sizes" class="entry-dropdown">
        <option value="3XL">3XL</option>
        <option value="2XL">2XL</option>
        <option value="XL">XL</option>
        <option value="L">L</option>
        <option value="M">M</option>
        <option value="YL">YL</option>
        <option value="YM">YM</option>
      </select> 
   <select name="number[]" id="amount" class="entry-dropdown">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
   </select>
   <select name="price[]" id="price" class="entry-dropdown">
        <option value="15">$15</option>
        <option value="12.5">$12.5</option>
        <option value="10">$10</option>
        <option value="0">Free</option>
   </select>
 </div>

My question I have is, I want to take the results and have them in a format where I can add everything up.

so it’ll say how many sizes of each I have, how many of each size, and the price. I’m assuming i need a multidimentional array.

I currently have:

 $('#order-submit').click(function(){

var size = [];
var price = [];
var quantity = []; 

$.each($('.entry-dropdown'), function() {

    size.push($(this).val());


});
  console.log(size);

But all this give me was a single array: [“XL”, “3”, “15”, “3XL”, “1”, “15”] (when I tested it)

What would be the best way to get that data in a useable format?

I hope that makes sense!
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-27T14:36:50+00:00Added an answer on May 27, 2026 at 2:36 pm

    You have to loop through each dynamic-sale element. Then, loop through the children, and add the values to a sub-array.

    var result = [];                               // <-- Main array
    $(".dynamic-sale").each(function(){
        var individual_result = [];                // <-- "sub"-array
        $(this).find("select").each(function(){
            individual_result.push($(this).val());
        })
        result.push(individual_result);            // <-- Add "sub" array to results
    });
    

    This method returns an array, consisting of an array with size, price and quantity.

    If you want to put these values in a separate array, use:

    var size = [],
        price = [],
        quantity = [];
    $(".dynamic-sale").each(function(){
        var selects = $(this).find("select");
        size.push(selects.eq(0).val());
        price.push(selects.eq(1).val());
        quantity.push(selects.eq(2).val());
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with the following dynamically added row: <input type=text name=statuseffective id=statuseffective_0
I have the following form (it is dynamically generated and I have a few
I have the following html form, which is generated dynamically: <ul class=precursorList> <li> Precursor
I have the following dynamically created HTML block: <form class=standard settingsPage method=post enctype=multipart/form-data name=account
I have the following form, which I have reduced as much as I can,
I have the following form for photo_album which uses the nested forms feature of
I have the following form <form name=myForm id=myForm method=post enctype=multipart/form-data action=script.php> and this jQuery
I have the following form code: # forms.py class SomeForm(forms.Form): hello = forms.CharField(max_length=40) world
i have the following form item { fieldLabel:'Username' ,id:username ,name:'username' ,allowBlank:false ,plugins:[Ext.ux.plugins.RemoteValidator] ,rvOptions: {
I'm looking at some Java classes that have the following form: public abstract class

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.