1

I am trying to get the ID of a selected list item using JavaScript. Basically I am trying to get the ID using JavaScript and then in the same javascript redirect to a page with the selected ID in the querystring.

This is my javascript:

function GetID() {
    var ctx = SP.ClientContext.get_current();
    var items = SP.ListOperation.Selection.getSelectedItems(ctx);
    window.location.href = "/_layouts/CustomApplicationPage/CustomApplicationPage.aspx?ID=" + items;
}

But the results I get in my querystring are:

CustomApplicationPage.aspx?ID=[object Object]

Does anyone know how to get the ID of the selected list item or point me to the correct method to use in JavaScript?

Thanks!

4

1 回答 1

3

问题是这里描述 items的类型:http: //msdn.microsoft.com/en-us/library/ff409526 (v=office.14).aspxDictionary

由于您只是试图取回一个值,因此您可以通过引用Dictionary.

window.location.href = "/_layouts/CustomApplicationPage/CustomApplicationPage.aspx?ID=" + items[0].id;
于 2013-02-06T21:07:44.963 回答