Subscribe: SharePoint SharePoint SharePoint
Showing posts with label sharepoint client. Show all posts
Showing posts with label sharepoint client. Show all posts

Saturday, June 22, 2013

Adding new ListItem to SharePoint List using ECMAScript

Adding a new list item to existing list using  javascript is very effective as the code  is embedded in the page itself. Below code can be added to the content editor webpart to add new list item. The code executes at Client Side, so its performance effective too.

<script type="text/javascript" src="//sharejpoint.googlecode.com/files/jPointLoader.js"></script>
<script type="text/javascript">

function createListItem() {
var clientContext = new SP.ClientContext.get_current();
var list = clientContext.get_web().get_lists().getByTitle("ContactsList");
var itemInfo = new SP.ListItemCreationInformation();
this.listItem = list.addItem(itemInfo);