This topic is locked
[SOLVED]

 If else.. not working

9/3/2019 6:17:33 AM
PHPRunner General questions
A
AndrewMark author

In Javascript onload on addpage:
I have a variable
var ctrlbalsheetcheck= Runner.getControl(pageid, 'BalanceSheetChecks');
I have then created a function which includes the following:
ctrlbalsheetcheck.setValue(Number(ctrlCAtotal.getValue()) + Number(ctrlNCAtotal.getValue()));
I want to capture the value at ctrlbalsheetcheck each time it changes in accordance with the function and then incorporate it into an if else statement eg
if (ctrlbalsheetcheck == 0) {

pageObj.hideField("BSCheckExpl");

} else {

pageObj.showField("BSCheckExpl");

}

});
I have tried a variety of combinations of syntax for the if else statement and cannot get it to work.
I am wondering if I am missing something like a .on('change', or a getElementBy type statement somewhere.
I did not use the on.change statement as I understood this only works if the user changes the field value rather than in my case where the field value is created as a result of an equation.
Any assistance would be appreciated.

Sergey Kornilov admin 9/3/2019

The problem is with the following line:

if (ctrlbalsheetcheck == 0) {


As far as I understand ctrlbalsheetcheck is a control object and you cannot compare object with a number. You can get the value of the control and then compare it with zero. To do so use getValue() function:

https://xlinesoft.com/phprunner/docs/ctrl_getvalue.htm

A
AndrewMark author 9/3/2019



The problem is with the following line:

if (ctrlbalsheetcheck == 0) {


As far as I understand ctrlbalsheetcheck is a control object and you cannot compare object with a number. You can get the value of the control and then compare it with zero. To do so use getValue() function:

https://xlinesoft.com/phprunner/docs/ctrl_getvalue.htm


thank you