Custom Section Color at Visual force page

Page Code

<apex:page standardController="Account">

<script>
    function colorPageBlock(pageblock, color) {
    if (pageblock != null) pageblock.firstChild.style.cssText = "background-color: " + color + ";";
    }
</script>
<apex:form >
    <apex:pageBlock title="My Content" mode="detail">
        <apex:pageBlockSection id="redSection" title="My Content Section" columns="2">
            <apex:inputField value="{!account.name}"/>
            <apex:inputField value="{!account.site}"/>
            <apex:inputField value="{!account.Fax}"/>
            <apex:inputField value="{!account.ParentID}"/>
            <script>colorPageBlock(document.getElementById("{!$Component.redSection}"), "red");</script>
        </apex:pageBlockSection>
        <apex:pageBlockSection id="greenSection" title="My Content Section" columns="2">
            <apex:inputField value="{!account.name}" onblur="alert('Hello')"/>
            <apex:inputField value="{!account.site}"/>
            <script>colorPageBlock(document.getElementById("{!$Component.greenSection}"), "green");</script>
        </apex:pageBlockSection>
        <apex:pageBlockSection id="orangeSection" title="My Content Section" columns="2">
            <apex:inputField value="{!account.name}"/>
            <apex:inputField value="{!account.site}"/>
            <script>colorPageBlock(document.getElementById("{!$Component.orangeSection}"), "orange");</script>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

</apex:page>



SnapShot

Comments

Post a Comment

Popular posts from this blog

Salesforce Spring 16 Release Exam (Maintenance Exam Q&A) for Developer 201 Admin

Show Hyper Link On Add Error in Salesforce Trigger

Show the Success Message before Redirecting the Detail page on Visualforce Page