I have managed, thanks to help here on the forum, to change the color of a line in a browse form based on conditions. Here is the code:
Code: Select all
if (nuFormType() == 'browse') {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd = '0'+dd
}
if(mm<10) {
mm = '0'+mm
}
today = yyyy + '-' + mm + '-' + dd;
$('[data-nu-column="0"]').each(function (index) {
var cellId = $(this).attr('id');
var cellValue = $('#' + cellId).html();
var rowNum = String(cellId).split('_')[1];
if ((cellValue < today) {
$("div[id^='nucell_" + rowNum + "']").css("color", "red");
}
if (cellValue == today) {
$("div[id^='nucell_" + rowNum + "']").css("color", "green");
}
});
}
The results:
Now I'm trying to add a 2nd condition: whether or not the values of another column are equal to 0 or 1 (in my case the column is the 2nd one from left).
My new code (without the 1st part that is not interesting here):
Code: Select all
$('[data-nu-column="0"]').each(function (index) {
var important = $('[data-nu-column="1"]').html();
var cellId = $(this).attr('id');
var cellValue = $('#' + cellId).html();
var rowNum = String(cellId).split('_')[1];
if ((cellValue < today) && (important === 1)) {
$("div[id^='nucell_" + rowNum + "']").css("color", "red");
}
if ((cellValue < today) && (important === 0)) {
$("div[id^='nucell_" + rowNum + "']").css("color", "orange");
}
if (cellValue == today) {
$("div[id^='nucell_" + rowNum + "']").css("color", "green");
}
});
Thanks
Marc