Hide Specific Dropdown Values | The place for Zendesk users to come together and share
Skip to main content
September 1, 2023
Question

Hide Specific Dropdown Values

  • September 1, 2023
  • 19 replies
  • 112 views

I am looking to hide specific dropdown values based on a form selection.

We use a form by product approach and for a specific product we only want the option to select High or Urgent as the priority.

Is this possible? 

19 replies

Ifra
Community Expert
September 3, 2023

@stephen27

 

Code for use:

var tagsToRemove = ['0000000000','1111111','2222222'];  //value to hide from dropdown

function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){
for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};

if (window.location.href.indexOf("456898764") > -1) { // form id for which you want to hide value of dropdown
removeTagsWeDontWant();
}



Note: 0000000000 my dropdown value and 456898764 my form id, remove this and add yours

and if I'm missing something let me know :)

ThanX.

 

Thank You
Stephen27Author
September 19, 2023

Thank you this worked great.

Based on how this executes it will remove all of the listed values from all dropdowns they appear in.

So if I have a priority field and an impact field both have a value of "low" available if I use this code "low" will be removed from both.

If there a simple way to target it for one field, priority, so that the "low" is only removed from priority but is available in impact?

April 23, 2024

Hi @ifra would you be able to tell me how to alter this code I wanted to remove specific field options based on another field selection? Thanks!

Ifra
Community Expert
April 25, 2024

Hi Noelle Cheng, do you want to hide dropdowns on specific forms OR  do you want to hide specific values of dropdown on specific forms?

 

 

Thank You
April 25, 2024

@ifra I want to hide specific values of a dropdown on a specific form if another value is selected on another dropdown.

 

On Form 789 there are the following fields

  1. Dropdown1 had options A, B, C, 
  2. Dropdown2 had options S, T, U, V, W

So if Dropdown1 had options A or B selected, then Dropdown2 would only show options S, T, U. But if Dropdown1 had option C selected, then Dropdown2 would show all the options S, T, U, V, W.

Erica
Employee
April 25, 2024
Hi Noelle! 
 
Do you mind if I move you into a ticket to see if I can better assist you? 
April 30, 2024

@Erica Girges, sure if you guys can assist? But Ifra has seem to been pretty helpful in the Zendesk community so just want to make sure I result in a resolution. Thanks.

April 30, 2024

Hi @ifra Just wanted to check my last comment. You've been so helpful and really appreciate your contribution to the Zendesk community! :)

Ifra
Community Expert
April 30, 2024

Hi Noelle Cheng, thanks for your recent comment.  :), I was traveling (between two states) that's why I wasn't able to answer.

I can help you to hide specific values of a dropdown on a specific form but without a second condition as that's not doable for me. I've tried so many times to work with the custom dropdown's value but didn't get any output.

 

 

Code for use: hide specific values of a dropdown on a specific form

 

var tagsToRemove = ['0000000000','1111111','2222222'];  //value to hide from dropdown

function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){
for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};

if (window.location.href.indexOf("456898764") > -1) { // form id for which you want to hide value of dropdown
removeTagsWeDontWant();
}



Note: 0000000000 my dropdown value and 456898764 my form id, remove this and add yours

 

Thanks 

 

Thank You
May 3, 2024

Hi @ifra So sorry to bug thank you though! I need the two options to still be visible so I may just conditionally hide the other fields if that option is selected. 

 

I hate to bother you about something unrelated from this post but you have been such a huge help in the community, I was wondering if you could help me on a code I seem to be having issues on regarding attachments based on a drop down selection? If I provide the link to my post, would you be open to helping me? Thanks!