+ Start a Discussion
anil Kumaranil Kumar 

PageBlock color not working

Hi All,

I am trying to change pageblock color using javascript. it is not getting changed getting error colorPageBlock is not defined in the console. please advise.

<script>
function colorPageBlock(pageblock, color) {
if (pageblock != null) pageblock.firstChild.style.cssText = “background-color: ” + color + “;”;

}
</script>


<apex:pageBlockSection id = "pbc" title="SELECT INFORMATION">

<apex:inputField value="{!Opportunity.LSS1__c}"/><br/>
<apex:inputField value="{!Opportunity.LSS2__c}"/><br/>
<apex:inputField value="{!Opportunity.LSS3__c}"/>

<script>colorPageBlock(document.getElementById("{!$Component.pbc}"), "red");</script>
</apex:pageBlockSection> 

Thanks,
Anil Kumar
Best Answer chosen by anil Kumar
anil Kumaranil Kumar
We need change the double cots to sinle cots

<script>
function colorPageBlock(pageblock, color) {
if (pageblock != null) pageblock.firstChild.style.cssText = 'background-color: ' + color + ';';

}
</script>