This topic is locked
[SOLVED]

Dropdown select ON CHANGE

8/5/2022 9:33:38 AM
PHPRunner General questions
S
Sayed author

Javascript OnLoad Event: code is below.

var ctrlStudent = Runner.getControl(pageid,'StudentID');

var ctrlRate = Runner.getControl(pageid,'Rate');
ctrlRate.makeReadonly();
var ctrlQTY = Runner.getControl(pageid,'QTY');

var ctrlAmount = Runner.getControl(pageid,'Amount');

function funcAmount(){
ctrlAmount.setValue((+ctrlRate.getValue())*(+ctrlQTY.getValue()));
};

ctrlStudent.on('change', funcAmount);
ctrlQTY.on('keyup', funcAmount);

When Dropdown StudentID is selected. It gives Amount (Total) of Rate and QTY.
There is no error in the code and even code is working fine.
But weird thing is, when I select StudentID the result produced is 1 step behind.
With first click nothing happens.
2nd click gives result of 1st click.
3rd click gives result of 2n click.
and so on...

Result means> ctrlStudent.on('change', funcAmount);

Any help would be appreciated. Thanks

S
Sayed author 8/6/2022

Replaced
ctrlStudent.on('change', funcAmount);
with
ctrlRate.on('change', funcAmount);

and its working...