Medron Posted October 3, 2018 Report Share Posted October 3, 2018 Are you able to use Calculated Fields in the Javascript code to change background colors? I cannot seem to get them to work. See code below... <a id="visi[@field:Patient_Name]"> <script> var isi = document.getElementById("visi[@field:Patient_Name]"); if('[@Calculated_Field_1]' > 30){ isi.parentNode.parentNode.style.backgroundColor = '#efe173'; } else if('[@Calculated_Field_1]' > 1440){ isi.parentNode.parentNode.style.backgroundColor = '#ef7f73'; } else{ isi.parentNode.parentNode.style.backgroundColor = '#FFFFFF'; } </script> Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted October 3, 2018 Report Share Posted October 3, 2018 Hi @Medron, Please make sure that you use correct event handler instead of a default Javascript event handler "on load". You need to something like this: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { <a id="visi[@field:Patient_Name]"> <script> var isi = document.getElementById("visi[@field:Patient_Name]"); if('[@Calculated_Field_1]' > 30){ isi.parentNode.parentNode.style.backgroundColor = '#efe173'; } else if('[@Calculated_Field_1]' > 1440){ isi.parentNode.parentNode.style.backgroundColor = '#ef7f73'; } else{ isi.parentNode.parentNode.style.backgroundColor = '#FFFFFF'; } }); </script> You can find more details about Caspio event handlers in the following article. https://howto.caspio.com/deployment/ Hope this helps. Regards, vitalikssssss Quote Link to comment Share on other sites More sharing options...
cheonsa Posted November 20, 2018 Report Share Posted November 20, 2018 Hi @Medron, You can also use HTML block to insert your code. Maybe this document can help: https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/how-to-dynamically-change-the-background-of-a-results-page/ Regards, kristina Quote Link to comment Share on other sites More sharing options...
RuisiHansamu Posted February 17, 2022 Report Share Posted February 17, 2022 Hi, just to update. Here is a forum post that is updated and similar to this topic. 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.