I wrote a java script to change background color of the title to green.But it does not seem to be working because of some reason i am unaware of.

Below is the VF page

<apex:page controller="AccountSummaryReportController" action="{!loadKeyAccounts}" >
function colorPageBlock(pageblock, color) {
    if (pageblock != null) pageblock.firstChild.style.cssText = “background-color: ” + color + “;



<apex:sectionHeader title="Account Summary Report as of : "  description="This Report Shows Records modified in last 31 days"/>
  <apex:form >

<apex:repeat value="{!objectMap }" var="ProgNameKey">

<apex:pageBlock title="{!ProgNameKey}">

        <apex:repeat value="{!objectMap [ProgNameKey]}" var="PlanNameKey">

            <apex:pageBlockSection title="{!PlanNameKey}" columns="1" id="greenSection" >
            <script>colorPageBlock(document.getElementById("{!$Component.greenSection}"), "green");</script>

               <apex:pageBlockTable value="{!objectMap [ProgNameKey][PlanNameKey]}" var="lstGrnRate"  border="1" columnsWidth="20%,10%,70%">
             <apex:column value="{!lstGrnRate.Account__r.Name}"/> 

             <apex:column value="{!lstGrnRate.Status__c }"/>
             <apex:column value="{!lstGrnRate.Account_Summary__c}"/>
  • check if you are getting value here document.getElementById("{!$Component.greenSection}") Aug 11 '16 at 11:35

You have a couple of issues.

Smart Quotes

“ ” are Smart Quotes (instead of "). Make sure when you use Office products that your quotes are not being changed on you.

Open String

 "background-color: "+ color + ";

There's no closing quote here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.