Jump to content

Javascript Formatting Disappears On Page 2 Of Results Etc

Recommended Posts

Hi all, I'm quite new to Caspio and to digital stuff so please bare with me. I'm currently using the code below to format the 7th column of my table red, amber of green depending on the value in each cell.

var elems = document.getElementsByTagName("td");for (var i=0, m=elems.length; i<m; i++) {
if (elems[i].innerHTML=="Low")  { elems[i].style.color="red";} 
if (elems[i].innerHTML=="Low")  {elems[i].style.backgroundColor="lightpink"}

if (elems[i].innerHTML=="Mid")  { elems[i].style.color="orange";}
if (elems[i].innerHTML=="Mid")  {elems[i].style.backgroundColor="wheat"}

if (elems[i].innerHTML=="High")  { elems[i].style.color="green";}
if (elems[i].innerHTML=="High") {elems[i].style.backgroundColor="LightGreen"}}

However, whenever I sort the table results by clicking the column headings or try to move onto the next page of results (by using the arrow buttons at the bottom of the page) all of the formatting generated by the code above disappears. Currently this code is located in the footer.


Does anyone know how to prevent this from happening?

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.

Reply to this topic...

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

  • Create New...