Thursday, July 2, 2009

Get people picker value using Javascript

Usage: The following javascript will return the current name value of a specific people picker on a SharePoint form page
Parameter: People picker number, which is the order of the people picker on the page.
Returns: Name of the person or group, not the internal domain name.


function getPickerInputElement(pickerNo) {
var result = "";
var j = 0;
var divs = document.getElementsByTagName("DIV");

for (var i=0; i <> 0) {
if (divs[i].id.indexOf("UserField_upLevelDiv") > 0) {
j++;
if (j == pickerNo) {
result = divs[i];
break;
}
}
}
return result;
}

No comments:

Post a Comment