Hiding fields in SharePoint Page's
(Newform.aspx / EditForm.aspx / Disp.aspx)
Open your website in the SharePoint Designer. Then open your Library. Go into the Form Section then Click on the page (Newform.aspx / EditForm.aspx / Disp.aspx). Click in advanced mode in Ribbon then only you were able to make the changes in the code. Then search for the Below Tag :
<asp:ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat = "server">
Now Copy the below code and paste it there.
You need to change the Field 1 and Field 2 values only .
<script
type="text/ecmascript">
ExecuteOrDelayUntilScriptLoaded(runCode,
"sp.js"); function
runCode() {
HideField("Expose to Customer / Partner",true); HideField("Field 1",true);
HideField("Field 2",true); } // Function To Hide Fields
function HideField(title,hide){
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++)
{
var mHead=title+"<SPAN class=ms-formvalidation> *</SPAN>";
if(el.childNodes[j].innerHTML == title || el.childNodes[j].nodeValue == title || el.childNodes[j].innerHTML==mHead)
{
var elRow = el.parentNode.parentNode ;
if(hide==true)
{
elRow.style.display = "none"; //and hide the row
}
else
{
elRow.style.display = "visible"; //and show the row
}
foundField = true ;
break;
}
}
}
if(foundField)
break ;
}
}
</script>
HideField("Expose to Customer / Partner",true); HideField("Field 1",true);
HideField("Field 2",true); } // Function To Hide Fields
function HideField(title,hide){
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++)
{
var mHead=title+"<SPAN class=ms-formvalidation> *</SPAN>";
if(el.childNodes[j].innerHTML == title || el.childNodes[j].nodeValue == title || el.childNodes[j].innerHTML==mHead)
{
var elRow = el.parentNode.parentNode ;
if(hide==true)
{
elRow.style.display = "none"; //and hide the row
}
else
{
elRow.style.display = "visible"; //and show the row
}
foundField = true ;
break;
}
}
}
if(foundField)
break ;
}
}
</script>
Wow...!! You're Done...!! Any Query....??
No comments:
Post a Comment