.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Add new iteam in sharepoint list using javascript?

Posted By:Sagar Pardeshi       Posted Date: September 02, 2013    Points: 40    Category: SharePoint    URL: http://www.dotnetspark.com  

This code of Add new item in sahrepoint list using sharepoint webservice using client code javascirpt
 

 <script type="text/javascript">

var x=document.getElementById("fname1").value;
var xmldoc;
var batch;
var FeedbackHTTP;
var ListName = 'TTT';

var UpdateNewItemXml= "<Batch OnError='Continue' ListVersion='1'>" 
                                                + "<Method ID=\"1\" Cmd=\"New\">" 
                                                + "<Field Name='Title'>"+x+"</Field>" 
                                                + "<Field Name='IDM'>EmployName</Field>" 
                                                + "</Method>" 
                                                + "</Batch>";
                                                            
                                                FeedbackHTTP = new ActiveXObject("MSXML2.XMLHTTP.3.0");

                                                FeedbackHTTP.Open("POST", "http://SvrName/_vti_bin/lists.asmx", false);
                                                FeedbackHTTP.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                                                FeedbackHTTP.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
                                                
                                                var strSOAP = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 
                                                + "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" 
                                                + "<soap:Body>" 
                                                + "<UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" 
                                                + "<listName>DemoList</listName>" 
                                                + "<updates>"+ UpdateNewItemXml + "</updates>" 
                                                + "</UpdateListItems>"
                                                + "</soap:Body>"
                                                + "</soap:Envelope>";
                                    
                                                FeedbackHTTP.Send(strSOAP); 

alert("Thank you! your suggestion has been submitted successfully.");


</script>


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend