The library can be implemented by adding a reference to it into a single page, a page layout, or a master page, depending upon your desired scope of use. The library requires v.1.3.2 of the jQuery library or greater. Note that versions prior to v0.5.0 will NOT work with jQuery 1.4+. If you would like to use jQuery 1.4+, you will need to upgrade to v0.5.0 or greater.

I recommend storing the jQuery library and our library in a Document Library in the root of your Site Collection and referencing it as needed, like this:
<script language="javascript" type="text/javascript" src="/jQuery%20Libraries/jquery-1.4.min.js"></script>
<script language="javascript" type="text/javascript" src="/jQuery%20Libraries/jquery.SPServices-0.5.0.min.js"></script>
Debug Mode, first implemented in v0.4.5, can be helpful in implementing solutions with the library. The debug mode functionality will be expanded over time.

Most releases of the library include both a minified and a normal version of the release. If you would like to understand the workings of the library, look at the normal version, but use the minified version for any production use.

Core

Function Name Short Description Introduced
$().SPServices This is the core function of the library, which you can use to make Ajax calls to the SharePoint Web Services. 0.2.3
$().SPServices.defaults With this defaults function, you can set the defaults for the remainder of the page life. This can be useful if you'd like to make many calls into the library for a single list or site. 0.2.4

Form Enhancements

Function Name Short Description Introduced
$().SPServices.SPCascadeDropdowns This is the first function we implemented which allows you to take advantage of the Web Services calls in a meaningful way. It allows you to easily set up cascading dropdowns on a list form. (What we mean by cascading dropdowns is the situation where the available options for one column depend on the value you select in another column.) 0.2.6
$().SPServices.SPDisplayRelatedInfo This function lets you display related information on forms when an option in a dropdown is chosen. 0.2.9
$().SPServices.SPLookupAddNew This function allows you to provide a link in forms for Lookup columns so that the user can add new values to the Lookup list easily. It is based on a blog post by Waldek Mastykarz. (see Credits)0.3.2
$().SPServices.SPRedirectWithID This function allows you to redirect to a another page from a new item form with the new item's ID. This allows chaining of forms from item creation onward. 0.4.0
$().SPServices.SPRequireUnique Checks to see if the value for a column on the form is unique in the list. 0.4.0
$().SPServices.SPSetMultiSelectSizes Sets the size of the boxes in a multi-select picker based on the values they contain. 0.4.8
$().SPServices.SPArrangeChoices Rearranges radio buttons or checkboxes in a form from vertical to horizontal display to save page real estate. 0.5.0

Utilities

Function Name Short Description Introduced
$().SPServices.SPGetCurrentSite This utility function, which is also publicly available, simply returns the current site's URL. It mirrors the functionality of the WebUrlFromPageUrl operation. 0.2.4
$().SPServices.SPDebugXMLHttpResult This function displays the XMLHttpResult from an Ajax call formatted for easy debugging. You can call it manually as part of your completefunc. 0.2.10
$().SPServices.SPGetCurrentUser This function returns the account for the current user. It is based on an inciteful trick from Einar Otto Stangvik (see Credits). 0.3.1
$().SPServices.SPGetLastItemId Function to return the ID of the last item created on a list by a specific user. Useful for maintaining parent/child relationships. 0.4.0
$().SPServices.SPGetDisplayFromStatic This function returns the DisplayName for a column based on the StaticName. 0.4.0
$().SPServices.SPScriptAudit The SPScriptAudit function allows you to run an auditing report showing where scripting is in use in a site. 0.4.8

General Instructions for Adding Functions to Your Pages

If you want to add functionalty to NewForm.aspx, then take a copy of the form, call it something like NewFormCustom.aspx, and add the jQuery into it. I generally put my script in the PlaceHolderMain ContentPlaceHolder, like this:
...
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type="text/javascript" language="javascript" src="/jQuery%20Libraries/jquery-1.3.2.min.js"></script>
<script type="text/javascript" language="javascript" src="/jQuery%20Libraries/jquery.SPServices-0.4.5.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $().SPServices.SPCascadeDropdowns({
            relationshipList: "Regions",
            relationshipListParentColumn: "Country",
            relationshipListChildColumn: "Title",
            parentColumn: "Country",
            childColumn: "Region"
        });
    });
</script>
...
Obviously, the src attributes should point to wherever you've put the .js files. Wrapping things in $(document).ready(function() means that the calls will be made once the page is fully loaded, i.e., the page is "ready".

Alternatively, you can place the code in a Content Editor Web Part (CEWP). I prefer the approach above (see the FAQs), but the CEWP approach works as well.

Once you've got the page set up the way you want it, right click on the list in the Folder List pane, select Properties, and then the Supporting Files tab. Choose the Content Type in the dropdown (NOT Folder) and then browse to your NewFormCustom.aspx to set it as the New Item Form. Click OK and you should be good to go.
Last edited Feb 1 at 4:32 PM by sympmarc, version 26
Comments
No comments yet.

Updating...
© 2006-2010 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2010.1.12.16187