Recent searches


No recent searches

Hide Specific Dropdown Values

Answered


Posted Sep 01, 2023

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? 


0

17

17 comments

image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

Stephen Keogh

 

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.

 

3


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?

0


Hi Ifra Saqlain 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!

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

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?

 

 

0


Ifra Saqlain 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.

0


image avatar

Erica Girges

Zendesk Developer Advocacy

Hi Noelle! 
 
Do you mind if I move you into a ticket to see if I can better assist you? 

0


@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.

0


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

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

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 

 

0


Hi Ifra Saqlain 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!

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

Noelle Cheng, okay I can try to solve this query, please share that link.

0


Ifra Saqlain Thank you so much! Looks like someone was able to help me out on it and their suggestion worked. I really appreciate all your contribution and help!

0


image avatar

이지훈(maclaude)

Zendesk Luminary

Hi. Ifra Saqlain

 

Currently, 'DOMNodeInserted' is not available as per the comment below, so the solution you mentioned does not work.

 

https://support.zendesk.com/hc/ko/community/posts/4409217680410/comments/7741431026074

 

Have you found any clever way to solve this? I really need your help.

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

Hi 이지훈(Lee jihoon),

 

Please explain your use case so I'll customize the code.

 

Thanks

0


image avatar

이지훈(maclaude)

Zendesk Luminary

Hi Ifra Saqlain.

 

I tried the code below and it worked in July.

My savior~! 

Is there any way to solve this?

 

$(document).ready(function() {
  removeOptions();
});


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

if (window.location.href.indexOf("900000000000") > -1) { // Ticket form ID for hide the drop down option
  var optionsToRemove = [etc', 'voc']; // Ticket field option tag
	removeOptions();
}

 

 

 

 

 

0


image avatar

이지훈(maclaude)

Zendesk Luminary

And in this code, the ticket form ID and tag are anonymized.

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

Hi Lee, 

 

You missed the inverted coma, try this and let me know :)

$(document).ready(function() {
  removeOptions();
});


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

if (window.location.href.indexOf("900000000000") > -1) { // Ticket form ID for hide the drop down option
  var optionsToRemove = ['etc', 'voc']; // Ticket field option tag
	removeOptions();
}

 

Thanks

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post