Showing posts with label jquery list items. Show all posts
Showing posts with label jquery list items. Show all posts

Saturday, November 30, 2013

Adding Item to SharePoint list using Jquery and SPServices

In this article I am going to show how to add list item to a SharePoint list using Jquery.

1. Create a SharePoint list (in my case I just created a list with name "testlist")

2. create a new page and insert a content editor webpart.

3. By default my "testlist" is created with Title field, so to make this article simple, I will be adding only Title filed from Jquery.

4. Now add below code to content editor webpart in Edit Source Mode

Place one HTML textbox to enter the title and One button to add the text box value to list when clicked.



<td><strong>List Item to be added</strong></td>

<td><input id="txtTitle" name="txtTitle" type="text" /></td>


<td><input name="ADD" id="btnADD" type="submit" value="Add Item to List" /></td></tr>


In order to work with Jquery and Sharepoint add below references for Jquery or download the files online and refer from your style library.

I will be referring online jquery.

<script src=" "></script>

<script src=" "></script>

Script :
<script type="text/javascript">

        $(document).ready(function () {

            $("#btnAdd").click(function () {
                var title = $("#txtTitle").val();


        function AddListItem(TitleField) {
                operation: "UpdateListItems",
                async: false,
                batchCmd: "New",
                listName: "testlist",
                valuepairs: [["Title", TitleField]],
                completefunc: function (xData, Status) {
                    alert("Data Saved! and Please check your List");