Javascript to compare fields

Can anyone help me with some JavaScript please....?

I currently have javascript setup to compare some table values with a fixed value and color them - this works great. (as shown below).

But I would like to compare some of them to another table value and then color code them accordingly. The other field is also on the same view.

For example I have teams that are paying deposits, then making final payments - I want to make sure the amount they've paid matches the amount i'm expecting based on the deposits and easily be able to highlight those that don't match.

This is what I currently have...

$(document).on('knack-view-render.view_276', function(event, view, data) {

$("#view_276 td.field_244").each(function() {

var backColor = ($(this).find("span").text().trim() == "100") ? "#ff0000" : "#ffffff";

$(this).css("background-color", backColor);



Thanks - I had a late night playing with scripts and ended up along those lines....

There is probably a more efficient way to do it - but it works :-)

$(document).on('knack-records-render.view_276', function (event, view, records) {
$("table tr").each(function () {
var depositValue = $(this).children("td:nth-child(6)").text().trim();
var paidValue = $(this).children("td:nth-child(7)").text().trim();

var depositHtml = $(this).children("td:nth-child(6)");
var paidHtml = $(this).children("td:nth-child(7)");

if (depositValue > paidValue) {

if (depositValue = paidValue) {

etc etc etc

You can use the 'data' parameter that is passed to your function, it should hold an array of json objects of the records currently visible.

Another option is to locate the other value on screen, using javascript selectors. I'm not sure about the order of loading on screen, so you might want to use a settimeout function to make sure data is on screen. You can also explore the possibility of having a hidden field on screen with an indication of color, and have your javascript locate that field.