MaraMara Posted May 14 Report Share Posted May 14 In the column STOCK, I have a Calculated field that sometimes shows numbers or is blank, in those cases I don't need to format the value. But when the Value is A B or C I need to color the text AND the background of the text A: red / B: yellow / C : green Quote Link to comment Share on other sites More sharing options...
ChrisCarlson Posted May 15 Report Share Posted May 15 You can achieve this by doing the following: Remove your STOCK field and add an HTML block that will act as the Stock column. Label the HTML Block as "STOCK". Disable HTML editor in the HTML block advanced options tab. Copy and paste the code below into the HTML block: Replace the 7 instances of FIELDNAME below with the name of your STOCK Field. You can adjust the color, background color, and padding in each statement below as needed. <div id="mydiv[@field:ID]"> </div> <SCRIPT LANGUAGE="JavaScript"> if ("[@field:FIELDNAME]" == "A") { document.getElementById("mydiv[@field:ID]").innerHTML ="<span style='color:white;background-color:red;padding:6px;'> [@field:FIELDNAME]</span>"; else if ("[@field:FIELDNAME]" == "B") { document.getElementById("mydiv[@field:ID]").innerHTML ="<span style='color:black;background-color:yellow;padding:6px;'> [@field:FIELDNAME]</span>"; else if ("[@field:FIELDNAME]" == "C") { document.getElementById("mydiv[@field:ID]").innerHTML ="<span style='color:white;background-color:green;padding:6px;'> [@field:FIELDNAME]</span>"; } else{ document.getElementById("mydiv[@field:ID]").innerHTML ="[@field:FIELDNAME]"; } </SCRIPT> See this article for more info: MaraMara 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.