Avatar of btuskey
btuskeyFlag for United States of America asked on

JQuery Running Total Dropdown Boxes

Hi All,

I have some code which was very helpful from padas here on this exchange.  Padas, if you see this, then you already know the code ;)

What I have is multiple, dynamically created PHP dropdown boxes.  You will see from the example code at the link below, how padas combined what I was doing into one, as well as, the image of what I want in red.  What I need now, is to take the totals of all rows and provide a running total from that.  In other words, I need to continue to show the running total for each row, plus, at the bottom of the page, show a running total of all sub-totals as the selections are made for each row.

Any input would be great, as always, I greatly appreciate it =)

JQuery Dropdown Running Total Example

Screenshot of Desired Result
JavaScriptWeb Languages and StandardsScripting Languages

Avatar of undefined
Last Comment
btuskey

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
leakim971

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
btuskey

Hi leakim971,

I only made a minor change for it to plugin and work (see below).  I really appreciate you taking the time to help me out on this =)

I haven't come across one person who hasn't been very helpful here, yet!

var total=0;
$('[name="shiftSelect_2"]').change(function(){ 
var className=$(this).attr('class');
total=0;
$('.'+className).each(function(){
var chosensm = $(this).val();
var asm = chosensm.split("_");
total=parseFloat(total)+parseFloat(asm[1],2);
});
$('#t_'+className).text(total);
$('input[name="'+className+'"]').val(total);
});
$('[name="shiftSelect_1"]').change(function(){ 
var className=$(this).attr('class');
total=0;
$('.'+className).each(function(){
var chosensm = $(this).val();
var asm = chosensm.split("_");
total=parseFloat(total)+parseFloat(asm[1],2);
});
$('#t_'+className).text(total);
$('input[name="'+className+'"]').val(total);
});
$("select[name^='shiftSelect_']").change(function()
{  
var big_total = 0;
$("select[name^='shiftSelect_']").each(function()
{ big_total += $(this).val().split("_").pop()*1; });
$("#big_total").text( big_total );
});

Open in new window

ASKER
btuskey

As usual, another helpful person here on experts-exchange...thank you leakim971!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23