0

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}" >
<script>
function colorPageBlock(pageblock, color) {
    if (pageblock != null) pageblock.firstChild.style.cssText = “background-color: ” + color + “;

}

</script>

<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}"/>
         </apex:pageBlockTable> 
              </apex:pageBlocksection>
        </apex:repeat>
</apex:pageBlock>
</apex:repeat>
  </apex:form>
</apex:page>
1
  • check if you are getting value here document.getElementById("{!$Component.greenSection}") Commented Aug 11, 2016 at 11:35

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .