This topic is locked
[SOLVED]

 Multiple Calculations on the Fly

3/2/2020 10:44:30 AM
PHPRunner General questions
H
Hopper author

I am attempting to do two calculations on my add page with JavaScript Onload Event. I am only able to get one value to populate.

I have searched the forum without luck. Any help is greatly appreciated!
Thanks

Hopper
var ctrlPrice = Runner.getControl(pageid, 'merchant_rate');

var ctrlQuantity = Runner.getControl(pageid, 'total_minutes');

var ctrlTotal = Runner.getControl(pageid, 'total_invoiced');
function func() {

ctrlTotal.setValue(Number(ctrlPrice.getValue()) Number(ctrlQuantity.getValue()));

};
ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);
var ctrlPrice1 = Runner.getControl(pageid, 'partner_rate');

var ctrlQuantity1 = Runner.getControl(pageid, 'total_minutes');

var ctrlTotal1 = Runner.getControl(pageid, 'total_cost');
function func() {

ctrlTotal1.setValue(Number(ctrlPrice1.getValue())
Number(ctrlQuantity1.getValue()));

};
ctrlPrice1.on('keyup', func);

ctrlQuantity1.on('keyup', func);

N
Nir Frumer 3/2/2020

hi

looks like you don't declare ctrlTotal1
hope it helps,

H
Hopper author 3/2/2020

Thanks.
Working

var ctrlPrice1 = Runner.getControl(pageid, 'merchant_rate');

var ctrlQuantity1 = Runner.getControl(pageid, 'total_minutes');

var ctrlTotal1 = Runner.getControl(pageid, 'total_invoiced');

var ctrlPrice = Runner.getControl(pageid, 'partner_rate');

var ctrlQuantity = Runner.getControl(pageid, 'total_minutes');

var ctrlTotal = Runner.getControl(pageid, 'total_cost');

function func() {

ctrlTotal1.setValue(Number(ctrlPrice1.getValue()) Number(ctrlQuantity1.getValue()));

ctrlTotal.setValue(Number(ctrlPrice.getValue())
Number(ctrlQuantity.getValue()));

};
ctrlPrice1.on('keyup', func);

ctrlQuantity1.on('keyup', func);
ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);

// Place event code here.