Help needed with adding values in repeating group

jeanl

Member
Hi

I have a list with a repeating group, containing two elements:
1. Job - dbjoin
2. Cost - CDD

So you can select a job done, and by means of the CDD element, you see all the costs associated with each job, and you can repeat the group for all jobs you need to do.

How can I add up all the values of the cost elements associated with all jobs done per form submission, meaning, how can I get a total cost for the jobs selected in each form submitted? My objective is to create a simple way to create a quotation based on the Jobs selected by a user.

Thank you in advance.

Jean
 
create a calculation element in the main group (the one that is not repeating).

add this code:

PHP:
$total = 0;
$costs = $data['tablename___costs_raw'];
foreach ($costs as $cost) {
  $total += $cost[0];
}
return $cost;
replace 'tablename___costs' with your cost's element name
 
Hi Rob

Thank you for the feedback. I tried this but the result is just a blank value. I did use the correct element name, and I created the calc element in the main group.
 
Hi - which form is this on? I guess I need to look at the code, element names etc to figure out what the difference is.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top