Dynamically change color of field based on value

[ad_1]

Hello @kristiaans

Thank you very much for using our plugin.

Yes, that’s possible.

I’ll try to describe the process with a hypothetical example.

Assuming the calculated field is the fieldname3, and its equation fieldname1+fieldname2.

You only should edit the equation as follows:


(function(){
var result = fieldname1+fieldname2,
    color = IF(result <= 0, 'red', 'green');

getField(fieldname3|n).jQueryRef().find('input').css('color', color);

return result;
})()

Note the fieldname3 includes the |n modifier (fieldname3|n). The plugin replaces the fields’ names with their values before evaluating the equations. The |n modifier tells the plugin you are referring to the field’s name instead of its value.

Best regards.

 

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