Show/Hide option in Select box depending on another select box.

Prashant Kumar6
Giga Guru

Hello Experts,

 

I have a request to show choice options based off of a selection made. I have a "requiring_admin_role_access" and "Duration of access" field (Both select box type field). 

 

My requirement is : Show all choices of "Duration of access" when  ""requiring_admin_role_access" is "Change_request".

And it should not show the "1 day, 3days, 5 days "option when other option(incident,problem,sc_request) is selected in ""requiring_admin_role_access". 

 

I am using on change client script(attached) to remove the option, my issue that I am facing is I can remove the choices, but they do not get readded back if "Change request" in "requiring_admin_role_access" is selected. 

What is the best way to do this?

 

PrashantKumar6_0-1681114660775.png

 

PrashantKumar6_1-1681114696470.pngPrashantKumar6_2-1681114716842.png

 

 

1 ACCEPTED SOLUTION

Namrata Ghorpad
Mega Sage
Mega Sage

Hello,

Add the below code in your script.

if(role=='change_request')
{
g_form.addOption('duration_of_access','1_day','1_day');
}

 

Regards,

Namrata

 

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

Hello @Prashant Kumar6 ,

 

In the script you need to also add the else condition and, in that condition, add the options you are removing.

g_form.addOption('contact_type', 'phone', 'Phone');

If this solves your problem, mark this as correct and helpful.

 

Regards

Anand

 

Namrata Ghorpad
Mega Sage
Mega Sage

Hello,

Add the below code in your script.

if(role=='change_request')
{
g_form.addOption('duration_of_access','1_day','1_day');
}

 

Regards,

Namrata