This topic is locked

Show field in Java

7/17/2019 3:31:17 AM
PHPRunner General questions
A
AndrewMark author

In the Javaonload, I am trying to show the field WhyBSdoesnotbal only when the field BalanceSheetChecks is not equal to 0. I have used the following code and it is hiding the field, but fails to show the field when BalanceSheetChecks is not equal to 0. I have used this type of function before successfully with "yes" "no" options but not with numbers. I am wondering if I have done something incorrect in the syntax.
pageObj.hideField("WhyBSdoesnotbal");

var ctrlbscheck = Runner.getControl(pageid, 'BalanceSheetChecks');
ctrlbscheck.on('change', function(e) {

if (this.getValue() !== 0){

pageObj.showField("WhyBSdoesnotbal");

} else {

pageObj.hideField("WhyBSdoesnotbal");

}

});

admin 7/17/2019

If this field a checkbox it will return "on" when it is checked. But there is an easier syntax you can use.

pageObj.hideField("WhyBSdoesnotbal");

var ctrlbscheck = Runner.getControl(pageid, 'BalanceSheetChecks');
ctrlbscheck.on('change', function(e) {

if (this.getValue()){

pageObj.showField("WhyBSdoesnotbal");

} else {

pageObj.hideField("WhyBSdoesnotbal");

}

});
A
AndrewMark author 7/17/2019



If this field a checkbox it will return "on" when it is checked. But there is an easier syntax you can use.

pageObj.hideField("WhyBSdoesnotbal");

var ctrlbscheck = Runner.getControl(pageid, 'BalanceSheetChecks');
ctrlbscheck.on('change', function(e) {

if (this.getValue()){

pageObj.showField("WhyBSdoesnotbal");

} else {

pageObj.hideField("WhyBSdoesnotbal");

}

});


A
AndrewMark author 7/17/2019

Thanks Sergey,
The BalanceSheetChecks is a numeric field. It is the result of a numeric calculation eg 2+3=5. If the result of the calculation does not equal the number 0, I need the WhyBSdoesnotbal field to be shown. This is what is not currently working with the syntax.

admin 7/18/2019

Then get the value of that field, convert it to Number and compare with zero. By default everything in Javascript is a string and not a number.