Page 1 of 1

Conditional format that recognizes > than or ≤

Posted: 2020-07-22 03:17
by jrcervantest
Respectfully request some assistance. For the following conditional format code, does anyone know what the replacement syntax would be for a value greater than (>) or less than or equal to (≤)?

V/r,
----------------------------------

<script>
$j(function(){
$j('.links-datecalc').each(function(){
var datecalc = $j(this).text();
if (datecalc == '9'){
$j(this).addClass('success');
}
if (datecalc == '7'){
$j(this).addClass('info');
}
if (datecalc == '-'){
$j(this).addClass('danger');
}
})
})
</script>

Re: Conditional format that recognizes > than or ≤

Posted: 2020-07-24 20:11
by jrcervantest
FOUND ANSWER :!:

Get rid of the quote around the numerical value.

----SAMPLE SYNTAX----
<script>
$j(function(){
$j('.links-datecalc').each(function(){
var datecalc = $j(this).text();
if (datecalc > 9){
$j(this).addClass('success');
}
if (datecalc < 7){
$j(this).addClass('info');
}
if (datecalc <= -2){
$j(this).addClass('danger');
}
})
})
</script>

Re: Conditional format that recognizes > than or ≤

Posted: 2020-07-31 10:00
by fbrano
How to format condition for Null value? Neither of these conditions works:
var status = $j(this).text();
a) if(status == 'Null'){
b) if(status == Null){
c) if(status == ''){

Re: Conditional format that recognizes > than or ≤

Posted: 2020-07-31 10:16
by jsetzer
You can output current value of status-variable to console of your browser's development tools and check it:

Code: Select all

console.log(status);
Could be:
  • undefined

    Code: Select all

    if (status === undefined) { ... }
    
  • null

    Code: Select all

    if (status === null) { ... }
    
  • empty string

    Code: Select all

    if (status === '') { ... }
    
  • or any value or object
Regards,
Jan

Re: Conditional format that recognizes > than or ≤

Posted: 2020-07-31 12:19
by fbrano
console said undefined, but still no collour