1

I built this function to find People Pickers by Field Title. Since the picker does not provide and TagName and Tile type of information and custom pages can have multiple people pickers, I used the NOBR tag which displays the title for each picker. This works flawlessly, but I think it can be sped up abit.

Please share your thoughts. Thanks you!!

function resetPickerInput(title){
    var result="";
    var tags=document.getElementsByTagName("NOBR");

    var len=tags.length;

    for(var i=0;i<len;i++){

        if(tags[i].innerHTML.indexOf(title)>-1){

            var div=tags[i].parentNode.parentNode.parentNode.getElementsByTagName("DIV");

            var divLen=div.length;

            for(var j=0;j<divLen;j++){
                if(div[j].name=='upLevelDiv'){
                    result=div[j];
                    break;
                }
            }
        }        
    }
    return result;
}
Dennis G
  • 21,405
  • 19
  • 96
  • 133
thesanerone
  • 87
  • 1
  • 10

1 Answers1

2

Yes, you are doing it more complicated than you should.

This jQuery example looks very promising (Get Value of People Picker in Sharepoint):

var User = $("textarea[title='People Picker']").val().split("\\");
Community
  • 1
  • 1
Dennis G
  • 21,405
  • 19
  • 96
  • 133
  • Great answer but how do I narrow it down to one people picker only? My pages typically have 4 or 5. That's kinda why I use nobr. Also to avoid using the dreaded long Ids sharepoint creates – thesanerone Sep 16 '11 at 23:29