I have some javascript that runs when a button is clicked. It processes the items that have been selected in a list web-part. However, I want to have two list web-parts on my page that refer to two different lists. When the button is clicked I want to know what the name of the list is that has items selected in, so that I can change the script logic according to the list web-part selected.
I have;
function getMailto() {
var ctx = SP.ClientContext.get_current();
var listId = SP.ListOperation.Selection.getSelectedList(); //selected list Id
var splist = ctx.get_web().get_lists().getById(listId);
alert(splist.get_name());
}
The alert(splist.get_name()) does not work of course because I do not know the syntax to get the name of splist.
Seems simple, if you know how!
EDIT:
If I do alert(listId); I see the list internal id {E7B55200-013C-4A48-A92F-F3D9CF859D88}. So I could use this for my script logic. However;
If (listId == "{E7B55200-013C-4A48-A92F-F3D9CF859D88}") {
...
}
Does not work. It does not appear to be a string. Can I convert it to one.
Either of the above requested solutions will enable me to do what I want. Help please!