开发者

Fairly New at Sharepoint Javascript. Need some feedback on custom function

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


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("\\");
  • How do I get text from people picker textarea using javascript only
    • uses this: $(".ms-inputuserfield #content").each(function(){...
  • Another example: Hide People Picker control in SharePoint List Forms
  • Set a People Picker’s Value on a Form – Revisited with jQuery
    • $(this).find("div[Title='People Picker']").html(userName)
  • Since you didn't state your version: Retrieve Email Address from sharepoint people picker using javascript a solution for SP2007.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜