calculate time of extensible row

lindsayg9092203

14-05-2015

Hy!

Sorry for my English. I need help.

I have a problem to find a simple script to calculate the time [HH:MM].

I have a table where the client can add many row.

The last column is for the total time per day.

Here's an example:

MondayPlaceKilo.Total Hours
+  -City1808:35
+  -other city305:05
+  -big city703:15
Totals28 km16:55

My question is how to calculate the big total time if he can add many row.

Thanks i'm very despair.

Accepted Solutions (0)

Answers (1)

Answers (1)

Salster123

04-06-2015

Obviously I don't know what you have called your rows and fields, so replace relevant bits.
it will be something like this...


//get a reference for each of the rows
//repeating fields have the same name so have to use this to reference them

var allHours = xfa.resolveNodes("total_hours[*]");


//find out how many there are
//the underscore is instead of instance manager

var nNodesLength = _my_row.count;

//set the initial sums to be zero
var nSum = 0;

//now add them all up for each instance of the rows
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
var item = allHours.item(nNodeCount);
//now add the hours
     nSum += item.theHours.rawValue;
}

//put into your grand total field
grand_total_hours.rawValue = nSum;

Hope this is of some help.