• Resolved Kristians Krauklis

    (@kristiaans)


    Hi,

    If calculation gives positive value, I would want it to be in green color, if it gives negative value I would want it to be in red color.

    Is that possible? I tried with chatgpt help but nothing. As the value in caclulation changes i want the color to change. It is for solar efficiency and needed additional energy, so there can be – number or positive number.

    Thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    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.

    Thread Starter Kristians Krauklis

    (@kristiaans)

    @codepeople bro! You are the best! Thanks a lot. This heleped. :))
    I will consider paid versions to do some exporting soon as well. Thank you!!

    Plugin Author codepeople

    (@codepeople)

    Excellent !!!!!

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dynamically change color of field based on value’ is closed to new replies.