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

User generated image
JavaScriptWeb Languages and StandardsScripting Languages

Avatar of undefined
Last Comment
btuskey
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of btuskey
btuskey
Flag of United States of America image

ASKER

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

Avatar of btuskey
btuskey
Flag of United States of America image

ASKER

As usual, another helpful person here on experts-exchange...thank you leakim971!
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo