Hide an option from drop down

Jen11
Tera Expert

Hello,

 

I have two drop down fields.  Depending on what is selected from the first drop down i would like to hide an option from the 2nd drop down field.  How can I do that?  

3 REPLIES 3

Muhammad Salar
Giga Sage

Hi @Jen11 
Where, for table or catalog item form?
field type?
and how are you adding choices? from script or added manually?

catalog item....added manually 

Hi @Jen11 
For 2nd drop down in which you want to remove, don't add choices manually.
Create an onchange client script on 1st dropdown variable and try this script with your fields and choice names

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        g_form.addOption('choice_2', 'optionA', 'OptionA');
        g_form.addOption('choice_2', 'optionB', 'OptionB');
        g_form.addOption('choice_2', 'optionC', 'OptionC');
        return;
    }

    g_form.addOption('choice_2', 'optionA', 'OptionA');
    g_form.addOption('choice_2', 'optionB', 'OptionB');
    g_form.addOption('choice_2', 'optionC', 'OptionC');

    if (newValue == 'calgary') {
        g_form.removeOption('choice_2', 'optionB');
    } else if (newValue == 'edmonton') {
        g_form.removeOption('choice_2', 'optionA');
    }

}