Divide share point newform.aspx in sections.
Requirement : Divide SharePoint newform.aspx in sections.
Solutions :
Added heading for each sections.
Function AddTrWithTd(ColumnNameWhereYouWantToAddHeading, FirstColumnText, SecondColumnText)
If you want SecondColumn then pass " "
Call this function in document.ready.
Change TD style and color as per requirement.
function AddTrWithTd(title,cell1Html,cell2Html) {
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";
if (el.childNodes[j] && el.childNodes[j].innerHTML)
{
if (el.childNodes[j].innerHTML == title || el.childNodes[j].innerHTML.startsWith(mHead))
{
foundField = true;
var elRow = el.parentNode.parentNode;
var newRow = elRow.parentNode.parentNode.insertRow(elRow.rowIndex);
var cell1=newRow.insertCell(0);
var cell2=newRow.insertCell(1);
cell1.setAttribute("class", "ms-formlabel");
cell1.style.borderTop= "1px solid black";
cell2.style.borderTop= "1px solid black";
cell1.style.borderBottom= "1px solid black";
cell2.style.borderBottom= "1px solid black";
newRow.style.backgroundColor="#ebf3ff";
var textToAssign ="<h3 class='ms-standardheader' style='font-size:12px;' ><nobr>" + cell1Html + "</nobr></h3>";
cell1.innerHTML = textToAssign;
textToAssign ="<h3 class='ms-standardheader' style='font-size:12px;' ><nobr>" + cell2Html + "</nobr></h3>";
cell2.innerHTML = textToAssign;
}
}
}
}
if (foundField)
break;
}
}
Solutions :
Added heading for each sections.
Function AddTrWithTd(ColumnNameWhereYouWantToAddHeading, FirstColumnText, SecondColumnText)
If you want SecondColumn then pass " "
Call this function in document.ready.
Change TD style and color as per requirement.
function AddTrWithTd(title,cell1Html,cell2Html) {
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";
if (el.childNodes[j] && el.childNodes[j].innerHTML)
{
if (el.childNodes[j].innerHTML == title || el.childNodes[j].innerHTML.startsWith(mHead))
{
foundField = true;
var elRow = el.parentNode.parentNode;
var newRow = elRow.parentNode.parentNode.insertRow(elRow.rowIndex);
var cell1=newRow.insertCell(0);
var cell2=newRow.insertCell(1);
cell1.setAttribute("class", "ms-formlabel");
cell1.style.borderTop= "1px solid black";
cell2.style.borderTop= "1px solid black";
cell1.style.borderBottom= "1px solid black";
cell2.style.borderBottom= "1px solid black";
newRow.style.backgroundColor="#ebf3ff";
var textToAssign ="<h3 class='ms-standardheader' style='font-size:12px;' ><nobr>" + cell1Html + "</nobr></h3>";
cell1.innerHTML = textToAssign;
textToAssign ="<h3 class='ms-standardheader' style='font-size:12px;' ><nobr>" + cell2Html + "</nobr></h3>";
cell2.innerHTML = textToAssign;
}
}
}
}
if (foundField)
break;
}
}
Comments
Post a Comment