Display and Hide choices based on a choice of another field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 04:49 PM
Hi All.
I am seeking some advice regarding my requirements in terms of the best approach.
I have a field which is called Name this the type of Choice and I have defined 4 values as the choices ('Payments', 'Card', 'Invoice', 'Statement').
I have another field called 'Status' and this is also the type of Choice and has 3 values as the choices ('Not Used', 'Testing', '3rd Party')
If you select either 'Payment', 'Invoice', or 'Statement' in the Name field then I would like two of the Status choices visible, these would be 'Not Used' and 'Testing'.
I only want the status of '3rd party' to be visible when the choice of Card has been selected in the Name field.
Any ideas on this.
thank you in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 11:19 PM
Hello @cstangoe
Greetings!
you can use on change client script on Name field.
if (isLoading || newValue !=='card') {
g_form.removeOption('status', '3rd party');
}
else if (newValue == 'card') {
g_form.clearValue('status');
g_form.addOption('status', 'Not used', '1');
g_form.addOption('status', 'Testing', '2');
g_form.addOption('status', '3rd party', '3');}
Please Mark the Answer as correct solution and helpful if helped!
Kind Regards,
Ravi Chandra.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 11:28 PM
function onChangeName() {
var nameField = g_form.getValue('field _name');
var statusField = g_form.getValue('field_name');
if (nameField == 'Payments' || nameField == 'Invoice' || nameField == 'Statement') {
statusField.removeOption('3rd Party');
} else if (nameField == 'Card') {
statusField.clearOptions();
statusField.addOption({value: 'not_used', label: 'Not Used'});
statusField.addOption({value: 'testing', label: 'Testing'});
statusField.addOption({value: '3rd_party', label: '3rd Party'});
}
}
please put right name of your field in the code and mark helpful and accept solution if it work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 04:50 AM
Hello @cstangoe
Use this Script :-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var name = g_form.getValue('name');
if(name=='payments'||name=='invoice'||name=='statement'){
g_form.clearOptions('status');
g_form.removeOption('status', '3rd Party');
}
if(name=='card){
g_form.clearOptions('status');
g_form.addOption('status', '3rd Party');
}
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh