Getting selected item id from SharePoint 2013 list view using JavaScript object model
<input type='button' value='Get Item IDs' onclick="clickMethod();"/>
<script language="javascript" type="text/javascript">
function clickMethod()
{
var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var mySeletedItems = '';
var i;
for (i in items)
{
mySeletedItems += '|' + items[i].id;
}
alert (mySeletedItems);
}
</script>
Now Save the page and select few items from the list and then click on the button, it will display you id's of the selected items in a dialog box as shown in the fig below:

Comments
Post a Comment