Sum repeating values on a form

madpato

Member
Hello

I've searched in the forum and the wiki on a way to do this, but it seems its not working for me, here is what i need to achieve:

I have a repeating group with 2 fields one for quantity and other for amount (this one is autofilled with autofil plugin). Now on another non repeating group (in the same form) i have a calc element where i want to show the total value of the sum of the other 2 values, typical cost calculation.
I read this wiki page: http://fabrikar.com/forums/index.php?wiki/form-javascript/#calculating-cost-in-a-repeat-group

Followed the steps but its not clear to me what should be the total element, is it a field? a calc? i have right now a calc but im not getting any result. This is my code i have setup as a onchange event on both quantity and amount elements:

Code:
var i = this.id.match(/_(\d+)$/)[1];
document.id('join___4___kamu_pedidos___total_'+i).value = parseFloat(document.id('join___4___kamu_pedidos_10_repeat___cant_'+i).value) * parseFloat(document.id('join___4___kamu_pedidos_10_repeat___cant_'+i).value);

Regards.
 
that didnt helped much... all it tells its how to show repeated group data, i need how to make the operation, something like:

Code:
$total=(int){element___cant_raw}*{element___value_raw};
return $total;

But it does not work :(
 
I'm hitting my head on wall in this same issue "Coding help needed in calc plugin" (can't post link yet)
 
You can't do calculations for repeat groups in a calc element.

You'll have to do it with Javascript, in a form JS file. There are some examples of that in the forums, try searching for some likely search terms. If you can't find an example, I'll create one for you.

-- hugh
 
Back
Top