Wednesday, June 2, 2010

How to add JavaScript to SharePoint list form

Ever want to add some javascript to list forms (NewForm.aspx, EditForm.aspx, DispForm.aspx) to show/hide items or something like that? You could try one of following ways (tested on WSS 3.0):
1. Use browser: browse to the form you want to add javascript. Add '&PageView=Shared&ToolPaneView=2' to the end of the URL then hit Enter. Then you could add a Content Editor webpart to the form and put your javascript there.
2. Use SharePoint Designer: open the form, search for MainPlaceHolder and paste the javascript just bellow the <asp:content> opening tag.

Be sure to include <script> and </script> tags with your javascript.

No comments: