Get SharePoint People Picker Value using Java Script

I was looking to find a solution to get the value entered in a people picker field using Java Script.

Google took me to this link http://sympmarc.com/2008/05/08/get-a-people-pickers-current-value-on-a-form/

This works by filling in a variable with the result of the function. You give the identifier as a parameter when you call it

var PickerPerson = getPickerInputElement("ff13"); // Here ff13 is your people picker control ID

function getPickerInputElement(identifier) {

var tags = document.getElementsByTagName(‘DIV’);
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if ((tempString.indexOf(identifier) > 0) && (tempString.indexOf(‘UserField_upLevelDiv’) > 0)){
var innerSpans = tags[i].getElementsByTagName(“SPAN”);
for(var j=0; j < innerSpans.length; j++) {
if(innerSpans[j].id == ‘content’) {
return innerSpans[j].innerHTML;
}
}
}
}
return null;
}

Advertisements

About Joseph Velliah
As a SharePoint Developer my professional interests tend to be technical and SharePoint focused. I run a blog at "SP RIDER" where you can expect to read HOW TOs and scenarios that I run into during my day to day job. I hope my posts will give back a little to the community that is helped me.

6 Responses to Get SharePoint People Picker Value using Java Script

  1. SharePoint Dummy says:

    Excellent thanks.

  2. cyberbrutus says:

    This can be done using 1 line of Jquery

    alert($(“.ms-inputuserfield #content”).text());

  3. prasadwt says:

    But how extract other attributes from the picker field? using this code ?

  4. see if you have any HTML tag with sid attribute

  5. alert($(“div[title=’People Picker’]”).text());

    Kindly check the quotas properly it will pop up you people picker name

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: