Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
You could add a callback to the load method with something like this:
Bear in mind that when injecting code into a QuickBase page it is very desirable to use as use as little code as possible if for no other reason then to reduce the cognitive load involved. This is why I used the $().load() method as it makes the task of extracting a fragment of HTML from a URL and slapping it into the DOM very simple. But you want to also modify the fragment of HTML slapped into the page so to build on using $().load() you have to grab the injected total, wrap it in a span that sets the color and slap it back into the DOM. Like this:
var urlLoad = url + " #VR_[DB_TableID]_[ReportID] tr:last td:last"
$("#QBU_Total").load(urlLoad, function() {
var total = parseFloat($("#QBU_Total").text());
if (total > 15000000) {
$(this).wrap("<span style='color:red'></span>");
} else {
$(this).wrap("<span style='color:blue'></span>");
}
});
Bear in mind that when injecting code into a QuickBase page it is very desirable to use as use as little code as possible if for no other reason then to reduce the cognitive load involved. This is why I used the $().load() method as it makes the task of extracting a fragment of HTML from a URL and slapping it into the DOM very simple. But you want to also modify the fragment of HTML slapped into the page so to build on using $().load() you have to grab the injected total, wrap it in a span that sets the color and slap it back into the DOM. Like this: