Coloring a line based on conditions
Posted: Tue Feb 05, 2019 5:48 pm
Hey there,
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:
The interesting part of the code is the 2nd part, after the value of "today" is gotten.
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):
But my lines are not colored in red anymore, nor in orange. I have no error in console. I'm sure it is due to how I get the value "important". Any idea on how to do it?
Thanks
Marc
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