Hide dropdown values from choice fields in SharePoint via jQuery

Hi all,
Yet another blogpost about jQuery. This time we are going to hide some values in a dropdown field. This is not a way to create a cascaded dropdown, but it could be helpful if you want the users to be able to not select something when a specific rule is met.
Example: you cannot set a status to reviewed if you are not a manager.

Code

<script language="javascript" type="text/javascript">
$(document).ready( function() {
  var dropdown = $(":input[title='DropdownField']");
  dropdown.find("option[value=’value 1’]").remove();
  dropdown.find("option[value='value 2']").remove();
  dropdown.find("option[value='value 3']").remove();
});
</script>

So, what does this do ?
When our page is loaded, we create a variable and fill it up with the dropdown field. Next we can remove all options in there.

About: Marijn

Marijn Somers (MVP) has over 14 years experience in the SharePoint world, starting out with SP2007. Over the years the focus has grown to Office 365, with a focus on collaboration and document management. He is a business consultant at Balestra and Principal Content Provider for "Mijn 365 Coach" that offers dutch employee video training. His main work tracks are around user adoption, training and coaching and governance. He is also not afraid to dig deeper in the technicalities with PowerShell, adaptive cards or custom formatting in lists and libraries. You can listen to him on the biweekly "Office 365 Distilled" podcast.


10 thoughts on “Hide dropdown values from choice fields in SharePoint via jQuery”

  1. Yogendra,
    What is going wrong ? Can you send your code to me ? (marijn.somers @ balestra.be – without spaces)

    1. Hi Marijn,

      I checked it once again and found that the Above code is working for a normal dropdown (a choice column) but not working for a lookup column.

      I have a dropdown which is taking value from another list as a lookup.

      can you guide me, how it will work.

  2. What harm will Removing Old Dropdown Fields From SharePoint actually do, when you have thousands of lines of data in a library with these field names?

Leave a Reply

Your email address will not be published. Required fields are marked *