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
btuskeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
Test page : http://jsfiddle.net/HR7mZ/
$('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


<tr>
      <td>Big Total: </td>
      <td id='big_total'></td>
    </tr>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
btuskeyAuthor Commented:
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

0
btuskeyAuthor Commented:
As usual, another helpful person here on experts-exchange...thank you leakim971!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.