Jump to content
  • 0

Changing cell color based on value of another cell




I have a report datapage where using javacript in an HTML block,  the color code changes in a Calculated Field depending on the value of 2 fields -


if(('[@calcfield:2]'-[@field:Orders_Quantity])/[@field:Orders_Quantity]> .05){

var line_id='[@field:Orders_Serial_Number]';
var line=document.getElementById(line_id).parentNode.parentNode;
var elems = line.getElementsByTagName("td");


'Orders_Serial_Number' is the auto-numbered unique id. Column 13 is 'Calculated Field 2'. This works but if I add or remove any columns, then the wrong field changes color. 

How do I reference Calculated Field 2 ([@calcfield:2]) in the line 'elems[13].style.backgroundColor="peru";elems[13].style.color="white";' instead of specifying the fixed column number 13?

Link to comment
Share on other sites

4 answers to this question

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.

Answer this question...

×   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...