If else (multiple conditions) | WordPress.org

[ad_1]

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.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer