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;
}

6 thoughts on “Get SharePoint People Picker Value using Java Script

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.