Cascading Drop down In SharePoint Lists using jQuery

Out-of-the-box SharePoint doesn't provide a way to cascade drop downs in list forms. Luckily, jQuery provides a way to implement cascading drop downs in SharePoint list forms. Here is the step by step implementation guide:

We need to have two more lists to implement this. Let's say:

List 1: Parent list, say: Country
cascading drop down sharepoint

List 2: Child list, say: Cities
cascading dropdown sharepoint list

List 3: Our target list, where we are going to implement the Cascading drop down.

So, Now:

1. Download the jquery-1.3.2.min.js by Jquery.com, from the below link
 http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.min.js

2. Download spservices (jquery.SPServices-0.5.6.min.js) from the codeplex link
http://spservices.codeplex.com/

3. After downloading upload these two files in a document library

4. In SharePoint Designer, create your own NewForm.aspx (and EditForm.aspx)

Search for this line in source code
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
and insert the following code, Just below the above line:
<script language="javascript" type="text/javascript" src="/address to document library/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/address to document library/jquery.SPServices-0.4.8.min.js"></script>
<script language="javascript" type="text/javascript">
 $(document).ready(function() {
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Cities",
   relationshipListParentColumn: "Country",
   relationshipListChildColumn: "Title",
   parentColumn: "Country",
   childColumn: "City",
   debug: true
  });
 });
</script>

Here:
  • relationshipList: “Cities” : this is the name of the relationsship list = the list containing parent and child
  • relationshipListParentColumn: “Country” : Column name from the Cities list
  • relationshipListChildColumn: “Title” : Column name from the Cities list
  • parentColumn: “Country”: Column name from the list where the drop down is = Vacation Plans
  • childColumn: “City”: Column name from the list where the drop down is = Vacation Plans
Cascading drop down example- What you will get as output is:
Cascading Drop down in SharePoint List Forms using jQuery
Verified that, cascading drop-down list method works on both SharePoint 2007 and SharePoint 2010.

Here is my another post on cascading drop down in SharePoint Online: SharePoint Online: Cascading drop-down list using jQuery

Cascading Drop down In SharePoint Lists using jQuery Cascading Drop down In SharePoint Lists using jQuery Reviewed by Unknown on January 04, 2011 Rating: 5

11 comments:

  1. Really love how everyone puts up this example but does not include the part after on how to get that value into the SharePoint list. This example only gives you the cascading drop down and does not populate the actual SharePoint list.

    ReplyDelete
  2. How fabulous this is, thanks for sharing, as for the last comment if you go to the website which its linked to you can see it in action and imitate this, thanks for this snippet of useful info
    Kris

    ReplyDelete
  3. Why does this script make customized button redirects no longer work?

    ReplyDelete
  4. The script works fine except when clicking on Submit button I get an unexpected error page...

    ReplyDelete
  5. Hi ,I want to perform cascading among 4 fields in a nintex form.Can u help me.

    ReplyDelete
    Replies
    1. Nintex has published a white-paper on this: http://connect.nintex.com/files/folders/tutorials_and_how_tos_nf2010/entry20327.aspx

      Delete
  6. Any suggestions on how to populate a 3d level cascading dropdown that has values based on teh 1st and 2d dropdowns? Marc Anderson said that SPCascade Dropdown CAML query won't work for this instance.

    ReplyDelete
  7. Hi, thanks for sharing your experience, it only works with Chrome and Edge and not with IE11, any suggestions?

    ReplyDelete
  8. Hi how can i use this to list quick edit mode

    ReplyDelete

Please Login and comment to get your questions answered!

Powered by Blogger.