Archive for March, 2012

March 27, 2012 Leave a comment

Recently I  came upon a requirement where the client  wanted the People Picker field to populate automatically with a user name depending on the some criteria and  not be able to change it.
I know I can disable the field but with the “Browse” icon a user can still change the People Picker value.
 So in order to hide the “Browse” field I went on a journey to figure out and finally found an easy way …
var divs1 = document.getElementsByTagName('a');    // Locate the "a" tag on the page
var z = 0;
for(var i =0; i < divs1.length; i++) //Loop through to find the browse icon
if(divs1[i].<a class="zem_slink" title="Internet Explorer" href="" rel="homepage" target="_blank">innerHTML</a>.indexOf('addressbook.gif') > 0) // The name of the image is "addressbook.gif"
if (z == 3)  // you have to manually count the total number of PeoplePicker on the page and target the one you want to disable
divs1[i].innerHTML = "</pre>
<img title="Browse" src="\&quot;/_layouts/images/addressbook.gif\&quot;" alt="Browse" />
<pre>"   // Append the innerHTML with display:none