Jump to content
  • 0

Conditional background color


jboder2

Question

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

  • 0

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>

 

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

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