Pages

Wednesday, September 29, 2010

Sharepoint: How to hide recurrence fields from Calender list using javascript

Put following javascript in the in the content place holder named 'PlaceHolderMain'. Put this code in EditForm.aspx, NewForm.aspx and DispForm.aspx

 <script type="text/javascript">
/*
  Detail: This code is to hide all three fields - 'All Day Event','Recurrence','Workspace' from the form
*/

_spBodyOnLoadFunctionNames.push("hideall()");
function hideall()
{
HideField("All Day Event");
HideField("Recurrence");
HideField("Workspace");
}

function HideField(title){
var header_h3=document.getElementsByTagName("h3") ;

for(var i = 0; i <header_h3.length; i++)
{
    var el = header_h3[i];
    var foundField ;
   if(el.className=="ms-standardheader")
    {
        for(var j=0; j<el.childNodes.length; j++)
        {
            if(el.childNodes[j].innerHTML == title || el.childNodes[j].nodeValue == title)
            {
                var elRow = el.parentNode.parentNode ;
                elRow.style.display = "none"; //and hide the row
                foundField = true ;
                break;
            }
        }       
    }
    if(foundField)
        break ;
}
}
</script>

1 comment:

Kam Sharma said...

Thank you so much! You are a star!

Kam Sharma