This topic is locked
[SOLVED]

Checkbox - works in Add/Edit but not View

11/25/2022 4:40:55 PM
PHPRunner General questions
dageci authorDevClub member

Hello,
I have a Checkbox control on Add/Edit/View and I would like to hide some controls if the checkbox is 'off'. This works on Add and Edit page, but on View page it always hides the fields no metter what the value of the checkbox is.
What I'm doing wrong?

Here is the code in Javascript onload event :

var ctrlworkingday = Runner.getControl(pageid, 'workingday');

if(ctrlworkingday.getValue() != 'on'){
pageObj.hideField("StartAt");
pageObj.hideField("ShiftDurationHours");
}
dageci authorDevClub member 11/25/2022

The solution was to use the event Before Display in View page with this code:

if ($values["workingday"]!="1") {
$pageObject->hideField("StartAt");
$pageObject->hideField("ShiftDurationHours");
}

If someone also got this challenge.