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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:53:06+00:00 2026-05-28T03:53:06+00:00

How can I find the values of two different select dropdowns and add the

  • 0

How can I find the values of two different select dropdowns and add the two values together upon selection(not submition) if they have the same “name” and then place the sum value into an array using jquery?

EDIT

For a little clarification, I am dynamically creating the list which needs to look like this

BOX A, BOX A, TITLE

BOX B, BOX B, TITLE

BOX C, BOX C, TITLE
etc…

Every list will be different and rarely the same. Next time the boxes could be D E or F. When selected(currently .onchange) All corresponding boxes need to be added together then pushed into a seperate array if the value is not empty…

var s=[sumOfAs, sumOfBs, sumOfCs];

I hope this helps…
Also the back end is PHP
THANKS!

EDIT

Here is the jquery code that pushes the first set of values into an array…

$("#selectionBox select").change(function(){
    s = [];
    $("#selectionBox select option:selected").each(function(){
        $("#selected_songs").text('');

        var v = $(this).val();
        if(v != ''){
            s.push(v);
        }
        if(s != ""){ 
            $('#selectionButton').show(); 
            var mw = $("#list_month_New").val();
            var dw = $("#list_day_New").val();
            var yw = $("#list_year_New").val();
            var t = $("#listTitle").val();
            if(mw == "" || dw == "" || yw == ""){
                $("#songListWarning").show();
            }else{
                $("#songListWarning").hide();
            }
        }else{
            $("#list_month_New").val();
            $("#list_day_New").val();
            $("#list_year_New").val();
            $("#listTitle").val();
            $('#selectionButton').hide();
        }
    });
    s.sort();
    jQuery.each(s, function(){
            O = "";
            O = this+"<br />";
            str = /&(.+)/.exec(O)[1];
            num = O.replace(/\-.*/, '');
            fullString = '<span style="color:black">'+num+'</span> - '+str;
            $("#selected_songs").append(fullString);
    });

I just need to figure out how to add another value to the initial value?

  • 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-28T03:53:06+00:00Added an answer on May 28, 2026 at 3:53 am
    var runningTotals = {};
    $('select').each(function() {
        var $this = $(this);
        var name = $this.attr("name");
        var val = runningTotals[name];
        if (!val) {
            val = 0;
        }
        val += +($this.val());
        runningTotals[name] = val;
    });
    

    Please refer to this fiddle


    EDIT
    Edited to update for the change edit you made

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

Sidebar

Related Questions

How can I find all column values in a column which have trailing spaces?
I can't find a way to read resource values in a controller
I have two SQL queries producing different results when I would expect them to
I have a set of elements/keys which I'm reading from two different config files.
So I have two tables in this simplified example: People and Houses. People can
I need to create two UIPickers Dynamically with different input values. I did n't
I want to get unique values from two different arrays. Two arrays are as
I'm trying to find a way to check my options in different select boxes
How can I do a Linq query for this? I have two xml documents,
Greetings, I have two questions regarding a DataTable.Select(): 1) How to escape potential apostrophes

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.