Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Using Javascript to add an item to a sharepoint list

$
0
0

Hello all, I am trying to use js to add an item entry to a sharepoint list here is my code below... This issue is that the button is not firing and when it did the code would skip down to the onQueryFailed message. can anyone point me in the right direction?  thanks in advance

 

siteUrl = 'http://portal/Pages/Login.aspx';

 

function updateListItem() {

    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('http://portal/Lists/Participant/AllItems.aspx');

    this.oListItem = oList.getItemById(4);

    oListItem.set_item('codetest', 'My Updated Title');

    oListItem.update();

    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {

    alert('Item updated!');
}

function onQueryFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

 


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>