+ Start a Discussion
Elad Kaplan 3Elad Kaplan 3 

How to get a page layout section name using a Javascript custom button

I have a javascript custom button I've created, and I want to go over an Opportunity standard page and get it's section names using a javascript.

Can it be done ? 
Anirudh SinghAnirudh Singh
Hi Elad,

Please find below the JavScript code to access Section Headers on a Standard Page Layout using a Custom Button:
//Access the Names of Section Headers
var pageBlockSections=document.getElementsByClassName('pbSubheader');
var allSectionNames=new Array();
for(var i=0; i<pageBlockSections.length; i++)
var childNodesHeader=pageBlockSections[i].childNodes[1].innerHTML;
var indexOfLessThan=pageBlockSections[i].childNodes[1].innerHTML.indexOf('<');
var sectionName=childNodesHeader.substring(0, indexOfLessThan);
//Push all the Section Headers Names in an array and then use it.
alert(sectionName); //sectionName will give you the name of Sections.

Please let me know if this helps.
If yes, please mark the Question as Solved.

Thanks and Regards,
Anirudh Singh