Hello,
I used the example in the help file to calculate values on the fly and edited it for my form. I need to do the following math: ((ProductCost + DeliveryCost) SalesTax) = Total. I have the following code:
var ctrlProductCost = Runner.getControl(pageid, 'ProductCost');
var ctrlDeliveryCost = Runner.getControl(pageid, 'DeliveryCost');
var ctrlSalesTax = Runner.getControl(pageid, 'SalesTax');
var ctrlTotal = Runner.getControl(pageid, 'Total');
function func() {
if ( ctrlProductCost.getValue()!='' && ctrlDeliveryCost.getValue() && ctrlSalesTax.getValue() && !isNaN(ctrlProductCost.getValue()) && !isNaN(ctrlDeliveryCost.getValue()) && !isNaN(ctrlSalesTax.getValue()))
ctrlTotal.setValue((parseFloat(ctrlProductCost.getValue()) + parseFloat(ctrlDeliveryCost.getValue())) parseFloat(ctrlSalesTax.getValue()));
else
ctrlTotal.setValue('');
};
ctrlProductCost.on('keyup', func);
ctrlDeliveryCost.on('keyup', func);
ctrlSalesTax.on('keyup', func);
This works correctly when I hit save, but it does not update the Total field as the other fields are changed. Do I have something wrong in my code?
Thanks,
Tim