This topic is locked
[SOLVED]

 Trigger a show/hide field if any value is selected in dropdown

12/10/2018 6:13:54 AM
PHPRunner General questions
woodey2002 author

Hi Guys
For an add page I have this nice Javascript onload event to show/hide a field if a checkbox is ticked or not.
I now would like to use a dropdown instead of a checkbox to trigger the show/hide.
Any ideas how I can modify the code below to show/hide if any value has been selected in a dropdown rather than a checkbox?
I can probably write an if (this.getValue()==" option "){ for each option in the dropdown however I would think that there is a more efficient way than that.

Many thanks,

J



var ctrlIvc50 = Runner.getControl(pageid, 'interventionCode50');

var ctrlIvc50T = Runner.getControl(pageid, 'interventionCode50Total');
pageObj.hideField("interventionCode50Total");
ctrlIvc50.on('change', function(e) {
if (this.getValue()=='on'){
pageObj.showField("interventionCode50Total");

ctrlIvc50T.addValidation("IsRequired");

}
else {
pageObj.hideField("interventionCode50Total");

ctrlIvc50T.removeValidation("IsRequired");

ctrlIvc50T.setValue('');



}

});