This topic is locked

multiple functions for on the fly calculations in onload event for add page

10/22/2021 2:58:04 PM
PHPRunner General questions
fmfsr author

I am on build 38040.

I have sucessfully setup a calculation on the fly in an add page, javasscript onload event, as per below example method.

var ctrlPrice = Runner.getControl(pageid, 'Price');
var ctrlQuantity = Runner.getControl(pageid, 'Quantity');
var ctrlTotal = Runner.getControl(pageid, 'Total');

function func() {
ctrlTotal.setValue(Number(ctrlPrice.getValue()) * Number(ctrlQuantity.getValue()));

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

I want to setup a second calculation in this page using different fields and a second function with appropriate var ctrlNEW=Runner.getControl(pageid, 'NEW') statements, appropriate math in function funcNEW(), and ctrlNEW.on('keyup',func); statements.

The second function/calculation does not trigger like the first.

How can i include 2 functions in the onload event?

admin 10/25/2021

It will work the same way with two or more functions. Just make sure you use different names for all controls and for additional functions.

Here is the article that explains how to troubleshoot Javascript errors:

Tedy 10/27/2021

make sure you call the correct function
ctrlNEW.on ('keyup', funcNEW)