1

Obviously it is possible to gather data from a form using JavaScript. Microsoft also claims that is possible to add items to a custom list using JavaScript, although I have not gotten that to work. My thinking is that I could collect form data from a public facing website using a couple of JavaScript functions then add it to a custom list.

Since I am new to Sharepoint, I have not gotten Javascript functions that are in my html code to execute properly. Are there any hoops I have to jump through first?

And also is there anything that would prevent me from gathering data, and putting it into a Sharepoint custom list using JavaScript? Permissions mainly I would guess.

This is my first go around with a Sharepoint website, so it might be a little too ambitious.

Thank you.

0
3

you can do CRUD operations using SPServices

e.g - Create Items

function CreateNewItem() {
$().SPServices({
    operation: "UpdateListItems",
    async: false,
    batchCmd: "New",
    listName: "Objectives",
    valuepairs: [["Title", "YourTitle"], ["Message=", "Message Text"]],
    completefunc: function(xData, Status) {
      alert("done");
    }
});}

Reference Link for SPServices https://spservices.codeplex.com/discussions/245285

CRUD operations through javascript client object model

To create list items, you create a ListItemCreationInformation object, set its properties

e.g. - Create Items

ClientContext clientContext = new ClientContext(siteUrl);
SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");

ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem oListItem = oList.AddItem(itemCreateInfo);
oListItem["Title"] = "My New Item!";
oListItem["Message"] = "Hello World!";
oListItem.Update();
clientContext.ExecuteQuery(); 

Referenced MSDN links

http://msdn.microsoft.com/en-us/library/office/hh185011%28v=office.14%29.aspx

http://msdn.microsoft.com/en-us/library/office/ee539976%28v=office.14%29.aspx

http://msdn.microsoft.com/en-us/library/office/hh185009%28v=office.14%29.aspx

hope it helps

6
  • Please add more details to your answer, if the link breaks it will be of little help to future readers as it's written now. – Nadeem Yousuf-AIS Dec 31 '13 at 5:31
  • i think this is trusted links... so i put here, if other links, i definately provide details with links – Hitesh Chandegara Dec 31 '13 at 5:45
  • Still it is better to provide details along with links. – Nadeem Yousuf-AIS Dec 31 '13 at 5:47
  • okay i will update my answer with details soon... thanks nadeem – Hitesh Chandegara Dec 31 '13 at 5:48
  • updated my answer – Hitesh Chandegara Dec 31 '13 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.