ECDatabase Posted October 19, 2016 Report Share Posted October 19, 2016 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. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 5, 2017 Report Share Posted July 5, 2017 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#]"); Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 5, 2017 Report Share Posted July 5, 2017 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> 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.