Use JQuery to Clear Out PeoplePicker

Hello,

   I have a Person or Group column in an editform.aspx that I need to blank out when the user clicks a dropdown.  I have the eventhandler completely set up but cannot seem to get the input value to clear out.  I have tried

$("input[id*='hiddenSpanData']").val(''');

 

$("input[id*='OriginalEntities']").val(''');

$("input[id*='HiddenEntityDisplayText']").val(''');

$("div[id*='divEntityData']").attr('description','');

$("div[id*='divEntityData']").attr('displaytext','');

$("div[id*='divEntityData']").attr('key','');
all no dice. There is only one People or Group column on the page. JQuery finds all the elements and sets them to string.empty but the input is not blanked out.

 

 

October 11th, 2011 8:55am

Hello!

I'm not sure that it will work with PeoplePicker, but I adjusted to clear the pickers of  BDC fields as the following:

var somebdcFieldUpLevelDiv = document.getElementById('ctl00_PlaceHolderMain_SomeBDCField_ctl00_99fc1877_4d3e_4d66_8efc_2648c544071b_Picker_upLevelDiv');
    if (somebdcFieldUpLevelDiv != null) {
        somebdcFieldUpLevelDiv.innerHTML = '';
       updateControlValue('ctl00_PlaceHolderMain_SomeBDCField_ctl00_99fc1877_4d3e_4d66_8efc_2648c544071b_Picker');
    }


Where updateControlValue is a built-in SharePoint JavaScript-function. Probably, you can use the same function, if not, try to find the similar, but which is for PeoplePicker.

ps and use proper element id(s)

Free Windows Admin Tool Kit Click here and download it now
October 11th, 2011 1:20pm

Hi,

The following code should do it.

$(document).ready(


function () {

document.getElementById('<%= spPeoplePickerID.ClientID %>' + '_upLevelDiv').innerHTML = "";

});

  • Marked as answer by Lugalzagesi Friday, March 01, 2013 5:05 PM
January 14th, 2013 8:52am

This one worked for me.

http://www.sharetechpoint.com/2015/09/clear-client-side-people-picker-control.html

Free Windows Admin Tool Kit Click here and download it now
September 6th, 2015 10:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics