startpoint
Active Member
Hi,
I have a repeated group with elements 'price', 'quantity' and 'subtotal'.
'Price' and 'quantity' are field elements and 'subtotal' is a calc element.
I have a calc element 'total' in another group with this code:
with settings:
calc on save: No;
Ajax calculation: Yes
calc onload: Yes;
Ajax observe fields: '{price},{quantity}'
Whit this settings after form is loaded total changed to 0.
If Ajax calculation set to No total is right, but without Ajax calculation.
What to change to fixed total updated at the time I change any of the values of price and quantity?
I have a repeated group with elements 'price', 'quantity' and 'subtotal'.
'Price' and 'quantity' are field elements and 'subtotal' is a calc element.
I have a calc element 'total' in another group with this code:
PHP:
$fields = array('table_name___subtotal');
$total = 0;
foreach ($fields as $field)
{
$value = JArrayHelper::getValue($data, $field . '_raw', array());
$thisSum = array_sum($value);
$total += $thisSum;
}
return $total;
with settings:
calc on save: No;
Ajax calculation: Yes
calc onload: Yes;
Ajax observe fields: '{price},{quantity}'
Whit this settings after form is loaded total changed to 0.
If Ajax calculation set to No total is right, but without Ajax calculation.
What to change to fixed total updated at the time I change any of the values of price and quantity?