Jump to content

Change Color on Tabular Row based on Calculated Fields


Recommended Posts

Hi all,

I am trying to change the color of rows in a tabular report based on expiration dates (calculated fields) and based on how many days until the document expires (90, 60, 30, 14). Here is the code I created by reading the Caspio article on how to change row colors:

 

[@field:RegistrationDateTime]
<a id="visi=[@field:Individual_NPI#]">

<script>
var isi=document.getElementbyID("visi[@field:Individual_NPI#]");
if("[@calcfield:1#]<=14){isi.parentNode.parentNode.style.backgroundColor="#FF0000"}
else if ("[@calcfield:1#]<='30'){isi.parentNode.parentNode.style.backgroundColor="#FF5500"}
else if ("[@calcfield:1#]<='60'){isi.parentNode.parentNode.style.backgroundColor="#FFF300"}
else if("[@calcfield:1#]<='90'){isi.parentNode.parentNode.style.backgroundColor="#23FF00"}
else if("[@calcfield:7#]<='14'){isi.parentNode.parentNode.style.backgroundColor="#FF0000"}
else if ("[@calcfield:7#]<='30'){isi.parentNode.parentNode.style.backgroundColor="#FF5500"}
else if ("[@calcfield:7#]<='60'){isi.parentNode.parentNode.style.backgroundColor="#FFF300"}
else ("[@calcfield:7#]<='90'){isi.parentNode.parentNode.style.backgroundColor="#23FF00"}


</script>

It's not working and I'm not sure why. Any help will be appreciated, I am a total JavaScript amatuer. :)

Link to comment
Share on other sites

  • 8 months later...

If you have Numbers and you want to compare numbers no need to have quotations so you need to change 

if("[@calcfield:1#]<=14){isi.parentNode.parentNode.style.backgroundColor="#FF0000"}

to

f([@calcfield:1#]<=14){isi.parentNode.parentNode.style.backgroundColor="#FF0000"}

Also you have a syntax error here. Change

var isi=document.getElementbyID("visi[@field:Individual_NPI#]");

To

var isi=document.getElementById("visi[@field:Individual_NPI#]");

 

 

Link to comment
Share on other sites

To change the background color of the cell, you can add HTML Block and add the field to that along with the code below

 

[@field:Approved^]
<a id="visi[@field:Individual_NPI]">
<script>
var isi=document.getElementById("visi[@field:Individual_NPI]");
if([@calcfield:1#]<=14) {isi.parentNode.style.backgroundColor="red"}
     else {{isi.parentNode.style.backgroundColor="green"} }
</script>

 

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.

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

Loading...
×
×
  • Create New...