Get selected (current) list item ID
-
20-12-2019 - |
Question
Is there a way to get a current list item ID using JavaScript?
Any help is appreciated.
Solution 2
<script type="text/javascript" src="/jquery-1.10.2.min.js"></script>
<script src="/jquery.SPServices-2013.02a.js" type="text/javascript"></script>
<script type="text/javascript">
var docurl = document.URL;
var beginindex = docurl.indexOf('?ID=') + 4;
var endindex = docurl.indexOf('&Source=');
var itemid = docurl.substring(beginindex, endindex);
</script>
OTHER TIPS
Use this function: GetUrlKeyValue("ID")
<script type="text/javascript" src="/jquery-1.10.2.min.js"></script>
<script src="/jquery.SPServices-2013.02a.js" type="text/javascript"></script>
<script type="text/javascript">
var itemid = GetUrlKeyValue("ID")
</script>
I found this is the easiest way
SP.ScriptHelpers.getDocumentQueryPairs()["ID"]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow