The SPServices library on Codeplex (http://spservices.codeplex.com) provides a lot of useful functionality to access SharePoint data.
One of the functions is the SPServices.SPCascadeDropdowns function. Here is a link to the documentation of this function: http://spservices.codeplex.com/wikipage?title=$().SPServices.SPCascadeDropdowns&referringTitle=Documentation
As explained on the site this function can be used to set up cascading dropdown on SharePoint forms. Repeat: on SharePoint forms.
Sometimes it’s handy to use cascading dropdown lists on a regular page or in a webpart. For this purpose I made a simple jQuery plug-in to provide in this need. The functionality is not that extended as the SPServices.SPCascadeDropdowns, but I’ll guess you get the point.
The purpose in this example is to make cascading dropdowns with countries and cities. This information is stored in two SharePoint lists and displayed in a Content Editor Webpart on a page.
Set up the lists
Create a list named Countries. Fill in some country names in the default Title column.
Create a list named Cities. Create a lookup column to the Countries list and name the column Country. Do not allow multiple values, the plug-in isn’t ready for that. Fill in some cities and link them to a country.
Add a document library e.g. with the name ICTLibrary. Of course you are free to choose the names, but be aware of the references in the code in this article, I use the names mentioned here.
Upload three items to this list:
The last file is the plug-in which provides the cascading functionality on a page.
Create the cascading dropdownlists
To create the cascading dropdownlists on a page is quite easy. Just paste the following code to a Content Editor Webpart on a page:
There are a few things to know about the options:
The name of the list which contains the parent/child relationships.
The name of the list which contains the parent items.
The StaticName of the values column in the parent list.
The StaticName of the child column in the relationshipList
The StaticName of the parent column in the relationshipList
The id of the child dropdownlist
The default text displayed in the dropdownlists
Most of the options are named the same as in the SPServices.SPCascadeDropdowns, because you are probably familiar with these names.
The cascading dropdownlists are looking like this now when nothing is selected:
The plug-in is helpful if you want simple cascading dropdown lists on a page or in a webpart with the use of SharePoint data.
Download the plug-in: [download#2] Updated version (November 30 2010; order by was hard-coded on ‘Title’ column)
For an extended plugin check out this post.