PHP JQuery Running Total Problem

Hi All,

I've been helped by a few wonderful people here so far and in my ongoing efforts to learn JQuery, I'm also running up against complex requirements (at least for me).

What I'm trying to do is provide a running total of employee hours by day (column).  You will see in the example code below, I have running total by row (week by employee) and combined total (all employee hours).  However, I'm trying to figure out how to also get a running total for all employees for the day (see screenshot totals, in green, below).

I use the select name, class and later split the value element in the jquery to get the values needed.  My issue is I'm not sure how to do it by day.  I can add the calendar date to the name, class or id but since I'm creating all the dropdowns dynamically, how do I use the calendar date and then call it in the jquery function with in a way which doesn't cause an issue with the functions already created?

Any help/input, as always, is greatly appreciated!  =)

You can see my existing code here:
Example In Green
Who is Participating?
quizwedgeConnect With a Mentor Commented:
Quick code sample to point you in the right direction. Give the table that has all of the selects an id of hours. Add the function below. It will output the selected value of the given day where curDayIndex is the index of the tr. So, to call it for day one, you would call getDayHours(1).

function getDayHours(curDayIndex) {
  var DayTotal = 0;
  $('#hours tr:gt(0)').find('td:eq(' + curDayIndex + ') option:selected').each(function(){console.log($(this).val());});
  return DayTotal;

Open in new window

Calling getDayHours(1) will output 1_8.5 and 10_0 in your example.

What you'll want to do with my sample code is change the console.log to splitting the value of the selects and adding it to DayTotal. Let me know if you need more info.
@btuskey did my solution help?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.