This topic is locked

Calculate sum of fields, then update total field

7/25/2018 9:40:43 PM
PHPRunner General questions
K
khansen188 author

I have six fields that I need to find the total sum of. These fields are called Round1, Round2, Round3, Round4, Round5, and Round6. I would like each time I load the list page, or an edit page for another field, called CurrentScore to be updated with the total sum of the fields named Round1-6.
I looked through the help files and tried to use the Totals Type option, but couldn't see how to add a totals calculation to the fileds as described https://xlinesoft.com/phprunner/docs/fields_order_and_totals.htm in the Totals Type section.
I also tried to calculate the value using the method described https://xlinesoft.com/phprunner/docs/how_to_calculate_values_on_the_fly.htm I modified the example code as below, however, I don't get the desired update.
var ctrlRound1 = Runner.getControl(pageid, 'Round1');

var ctrlRound2 = Runner.getControl(pageid, 'Round2');

var ctrlRound3 = Runner.getControl(pageid, 'Round3');

var ctrlRound4 = Runner.getControl(pageid, 'Round4');

var ctrlRound5 = Runner.getControl(pageid, 'Round5');

var ctrlRound6 = Runner.getControl(pageid, 'Round6');
function func() {

ctrlTotal.setValue(Number(ctrlRound1.getValue()) + Number(ctrlRound2.getValue())+ Number(ctrlRound3.getValue()) + Number(ctrlRound4.getValue()) + Number(ctrlRound5.getValue()) + Number(ctrlRound6.getValue()));
};
What do I need to do so that the field named CurrentScore is automatically updated with the appropriate values?

HJB 7/26/2018



I have six fields that I need to find the total sum of. These fields are called Round1, Round2, Round3, Round4, Round5, and Round6. I would like each time I load the list page, or an edit page for another field, called CurrentScore to be updated with the total sum of the fields named Round1-6.
I looked through the help files and tried to use the Totals Type option, but couldn't see how to add a totals calculation to the fileds as described https://xlinesoft.com/phprunner/docs/fields_order_and_totals.htm in the Totals Type section.
I also tried to calculate the value using the method described https://xlinesoft.com/phprunner/docs/how_to_calculate_values_on_the_fly.htm I modified the example code as below, however, I don't get the desired update.
var ctrlRound1 = Runner.getControl(pageid, 'Round1');

var ctrlRound2 = Runner.getControl(pageid, 'Round2');

var ctrlRound3 = Runner.getControl(pageid, 'Round3');

var ctrlRound4 = Runner.getControl(pageid, 'Round4');

var ctrlRound5 = Runner.getControl(pageid, 'Round5');

var ctrlRound6 = Runner.getControl(pageid, 'Round6');
function func() {

ctrlTotal.setValue(Number(ctrlRound1.getValue()) + Number(ctrlRound2.getValue())+ Number(ctrlRound3.getValue()) + Number(ctrlRound4.getValue()) + Number(ctrlRound5.getValue()) + Number(ctrlRound6.getValue()));
};
What do I need to do so that the field named CurrentScore is automatically updated with the appropriate values?


https://www.xlinesoft.com/articles/how_to_use_calculated_fields.htm
http://asprunner.com/forums/topic/21091-implementing-running-total-in-phprunner/
... for inspiration purposes only ...