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


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;}

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

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

| improve this answer | |
  • I will look into this ASAP and give that a try. Thank you for the quick response and additional link! – Steve Jan 27 '15 at 16:38

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.