• Resolved Alberto

    (@albertobellipario)


    Hi.
    I'm triyng to set a warning based on multiple conditions.
    
    Fieldname33 is a currency field
    Fieldaname40 is a radio button (first 4 fields value is zt1, last field value is zt2)
    Fieldname41 is a calculated field with function inside
    
    Conditions:
    No selection on radio = soft WARNING
    If zt1 AND fieldname33 value > 150000 = WARNING
    If zt2 AND fieldname33 value > 100000 = WARNING
    Else = OK
    
    I started from your previuos example on another thread:
    
    (function(){
    var va = fieldname33;
    var zt = fieldname40|r,
    tag = getField(fieldname41|n).jQueryRef().find('input');
    
    if ((zt != 'zt1') || (zt != 'zt2')) {
    
    tag.css({background:'orange', color:'white', fontWeight:'bold'});
    return 'Seleziona Zona Territoriale';
    }
    
    else if (zt == 'zt1' && va >150000) {
    
    tag.css({background:'red', color:'white', fontWeight:'bold'});
    return 'Rischio non assumibile per valore massimo superiore a € 150.000,00';
    }
    
    else if ((zt == 'zt2' && va >100000) {
    
    tag.css({background:'red', color:'white', fontWeight:'bold'});
    return 'Rischio non assumibile per valore massimo superiore a € 100.000,00';
    }
    
    else {
    
    tag.css({background:'green', color:'white', fontWeight:'bold'});
    return 'OK';
    }
    
    })()
    
    Where I'm wrong?
    Or there is a better way to?
    
    Thanks in advance.
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @albertobellipario

    There is an extra parenthesis in the piece of code:

    } else if ((zt == 'zt2' && va > 100000) {

    The correct would be:

    } else if (zt == 'zt2' && va > 100000) {

    Best regards.

    Thread Starter Alberto

    (@albertobellipario)

    Thank you, I corrected the error.

    But the “else if” and the final “else” are not applied.

    EG.

    If I enter a value of “€ 101,000” in fieldname33 and then select the fifth option in the radio button (value zt2), the third condition does not apply.
    The soft warning of the first If condition remains.

    If the syntax is correct, what could it be due to?

    Plugin Author codepeople

    (@codepeople)

    Hello @albertobellipario

    The first condition covers the others. So, you should use the “and” logical operator:

    if (zt != 'zt1' && zt != 'zt2') {

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘If else (multiple conditions)’ is closed to new replies.