jboder2 Posted October 16, 2021 Report Share Posted October 16, 2021 i can't get the background to change colors conditionally, this is what I'm using. Please let me know if you see the error <a id="visi[@field:Orders_Coverage_Confirmed]"> <script> var isi = document.getElementById("visi[@field:Orders_Order_ID]"); if('[@field:Orders_Coverage_Confirmed]' == 'Yes'){ isi.parentNode.parentNode.style.backgroundColor = '#0000FF'; } else{ isi.parentNode.parentNode.style.backgroundColor = '#FF0000'; } </script> Quote Link to comment Share on other sites More sharing options...
0 CoopperBackpack Posted October 19, 2021 Report Share Posted October 19, 2021 Hello @jboder2, As far as I understand you used this article as a reference https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/how-to-dynamically-change-the-background-of-a-results-page/ The idea here is to have some unique value in the <a> tag, to store it in a variable, and then use this variable to refer to the whole record. Could you replace the [@field:Orders_Coverage_Confirmed] field in the <a> tag with the [@field:Orders_Order_ID] field? This should fix the issue. <a id="visi[@field:Orders_Order_ID]"> <script> var isi = document.getElementById("visi[@field:Orders_Order_ID]"); if('[@field:Orders_Coverage_Confirmed]' == 'Yes'){ isi.parentNode.parentNode.style.backgroundColor = '#0000FF'; } else{ isi.parentNode.parentNode.style.backgroundColor = '#FF0000'; } </script> Quote Link to comment Share on other sites More sharing options...
0 Queso Posted January 28, 2022 Report Share Posted January 28, 2022 Hey @jboder2, I have encountered this one before, and it's because I typed the field names directly into the code, instead of selecting them using the field picker. The problem is fixed when I used the field picker for the code to insert the needed fields. Here is what I am talking about: I hope this helps. Quote Link to comment Share on other sites More sharing options...
Question
jboder2
i can't get the background to change colors conditionally, this is what I'm using. Please let me know if you see the error
<a id="visi[@field:Orders_Coverage_Confirmed]">
<script>
var isi = document.getElementById("visi[@field:Orders_Order_ID]");
if('[@field:Orders_Coverage_Confirmed]' == 'Yes'){
isi.parentNode.parentNode.style.backgroundColor = '#0000FF';
}
else{
isi.parentNode.parentNode.style.backgroundColor = '#FF0000';
}
</script>
Link to comment
Share on other sites
2 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.