Jump to content

Creating Available Stock traffic lights - Color Formatting text AND text background Based on Cell Value in a table

Recommended Posts

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>


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]";




See this article for more info:


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...