This topic is locked
[SOLVED]

 View field on condition

7/25/2017 6:27:55 PM
PHPRunner General questions
H
Hertz2P author

I can use this code in events / add page / JavaScript OnLoad event to hide a field, and only show it if the answer of the other field is "yes".



pageObj.hideField("describe");

var ctrlOne = Runner.getControl(pageid, 'injured');

ctrlOne.on('change', function(e) {
if (this.getValue() == "yes"){

pageObj.showField("describe");

} else {

pageObj.hideField("describe");

}

});


I've now changed the first field to a checkbox instead of a "yes" or "no" dropdown. I can't seem to get the conditional code to work anymore. I thought it should look something like this:



pageObj.hideField("describe");

var ctrlOne = Runner.getControl(pageid, 'injured');

ctrlOne.on('change', function(e) {
if (this.getValue() == 1){

pageObj.showField("describe");

} else {

pageObj.hideField("describe");

}

});



but that doesn't work. I've tried it a bunch of other ways and still haven't gotten it correct. Any ideas on what I'm doing wrong?
Thanks!

jadachDevClub member 7/25/2017

Try if (this.getValue() == 'on'){

H
Hertz2P author 7/25/2017



Try if (this.getValue() == 'on'){


That's the ticket.
Thank you kind sir!