[SalesForce] Changing color of field label when Checkbox == True

I asked this question on another forum, but I guess it would make a bit of sense to ask on a SalesForce forum. My goal is to have a checkbox field named "Inactive" and whenever the checkbox == false, "Inactive" will display as the default font color. When checkbox == True, "Inactive" will display as the color red.

My previous post yielded one response, in which using JavaScript was suggested. While I'm not the best at writing Java, the concept seems simple enough to try and write on my own.

I think I'm just struggling figuring out the specific placement in SalesForce, to begin writing the code. Also, are there multiple components to writing such code, or can I develop a simple piece of script and just have it run each time the value of the checkbox is changed.

Any suggestions would be greatly appreciated.

Thank you

Best Answer

If this is inside a Visualforce (VF) Page and you are using the standard VF tags to accomplish this with CSS and the styleClass attribute.

For example:

<apex:page standardController="object">
    <style type="text/css">
        .activeStyle { color: green; }
        .inactiveStyle {color: red;}
    </style>

<apex:outputText value="{!object.Active__c}" styleClass="{!IF(object.Active__c,'inactiveStyle',activeStyle')}"/>
</apex:page>

Guide on Custom Styles for Visualforce: http://www.salesforce.com/docs/developer/pages/Content/pages_styling_custom.htm