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

18

18 comments

@Ifra Saqlain, I have added this snippet at the bottom of my script.js but am still seeing the option in my drop-down… Any suggestions?

function removeOptions() {
 $('.nesty-panel').on('DOMNodeInserted', function(e){
   for(var i in optionsToRemove) {
       $('li#' + optionsToRemove[i]).remove();
   }
 });
};
if (window.location.href.indexOf("11122233344456") > -1) { // Ticket form ID for hide the drop down option
 var optionsToRemove = ['my_field_value_tag']; // Ticket field option tag
    removeOptions();
}

11122233344456 is the Form ID placeholder and my_field_value_tag is the value tag for the option in the field I want to hide

0


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


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

0


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


Hi 이지훈(Lee jihoon),

 

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

 

Thanks

0


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


1263169183150 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


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

0


Hi 1263169183150 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


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


Sign in to leave a comment.

Didn't find what you're looking for?

New post