This topic is locked

Enable/Disable Fields Conditionally In Dialog API

5/21/2026 15:13:14
PHPRunner General questions
C
copper21 author

I have two fields in a dialog pop-up. Based on the selection made to the first control, I would like to disable the second control. I have tried all sorts of things and have not been successful. Could someone assist with this? I have tried to treat it like a JavaScript onload event, but this is not working. I think I place the code for this in the "afterCreate" function?

Runner.Dialog( {
title: 'Group Update',
fields: [{
name: 'Add or Remove Login Group?',
type: 'radio',
required: true,
horizontal: true,
options:

[
['Adding','Add'],
['Removing','Remove'],
['Resetting', 'Reset To Default'],
['Deleting', 'Delete All']
]
},
{
name: 'Select Login Group',
type: 'lookup',
required: true,
options:
[
[1,'Group 1'],
[2,'Group 2'],
[3, 'Group 3'],
[4, 'Group 4']
]

}
],

afterCreate: function(popup, controls)
{
controls[0].on("change", (e) => {
if (controls[0].getValue()== 'Deleting' )
{
controls[1].setDisabled();
} else {
controls[1].setEnabled();
}
});
},
ok: 'Update Login Group(s)',
cancel: 'Cancel',
beforeOK: function( popup, controls ) {

//OK Button Code

}

});