Hiperf Posted November 15, 2022 Report Share Posted November 15, 2022 I have this code, and it works perfectly, but when I go to add a 3 option, the colors disappear. WORKS <script>document.addEventListener('DataPageReady', function(event) { const statusField= document.querySelectorAll('td:nth-child(12)'); // '12' is field number for which styles have to be applied statusField.forEach(element => { if (element.innerHTML === 'Expires in (30 days)') { element.style.cssText = 'background: #FFA200; font-weight: bold; color: #FFFFFF'; } else if (element.innerHTML === 'Expires in (60 days)') { element.style.cssText = 'background: #FBFF00; font-weight: bold; color: #000000'; } }); }); </script> DOES WORK Sorry I had a typo I fixed it is now working. <script>document.addEventListener('DataPageReady', function(event) { const statusField= document.querySelectorAll('td:nth-child(12)'); // '12' is field number for which styles have to be applied statusField.forEach(element => { if (element.innerHTML === 'Expires in (30 days)') { element.style.cssText = 'background: #FFA200; font-weight: bold; color: #FFFFFF'; } else if (element.innerHTML === 'Expires in (60 days)') { element.style.cssText = 'background: #FBFF00; font-weight: bold; color: #000000'; } else if (element.innerHTML === 'Expired') { element.style.cssText = 'background: #FF0000; font-weight: bold; color: #FFFFFF'; } }); }); </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.