• Resolved gerikg

    (@gerikg)


    (function(){
        if(fieldname8*fieldname9*fieldname10*fieldname11==0)
    { 
    return "Red";
    }
    else if(fieldname8*fieldname9*fieldname10*fieldname11<9)
    { 
    return "Yellow";
    }
    else
        {
            return "Green";
        }
    })()

    I want the font color, Red to be color=red, Yellow to be color=yellow, etc

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

    (@codepeople)

    Hello @gerikg

    If the calculated field is, for example, the fieldname123, you can use the getField operation to get its object representation. The getField operation requires the number part of the field’s name. The equation would be similar to:

    (function(){
        var field = getField(123).jQueryRef().find('input'),
            color = 'Green';
        if(fieldname8*fieldname9*fieldname10*fieldname11==0) color = 'Red';
        else if(fieldname8*fieldname9*fieldname10*fieldname11<9) color = 'Yellow';
       
        field.css('color', color);
        return color;
    })()

    Best regards.

    Thread Starter gerikg

    (@gerikg)

    I appreciate your help. Any thought of adding this to the documentation or blog on your website? I have 7689327 questions and I can’t “Script”

    Plugin Author codepeople

    (@codepeople)

    Hello @gerikg

    I’ll keep this in mind for a new blog post ??

    If you have any other question do not hesitate in contact me again.

    Best regards.

    Thread Starter gerikg

    (@gerikg)

    OKay I figured that the code says if the answer is X then the font color is X.

    After using your code the yellow is unreadable behind a white background.

    1. Is this javascript?
    2. can yellow be dark yellow? I’m assuming you have to rework everything.

    Plugin Author codepeople

    (@codepeople)

    Hello @gerikg

    You can use colors code instead of colors names.

    (function(){
        var field = getField(123).jQueryRef().find('input'),
            color = 'Green',
            color_code = '#439832';
        if(fieldname8*fieldname9*fieldname10*fieldname11==0)
        {
            color = 'Red';
            color_code = '#983232';
        }
        else if(fieldname8*fieldname9*fieldname10*fieldname11<9) 
        {
            color = 'Yellow';
            color_code = '#bfbd33';
        }   
        field.css('color', color_code);
        return color;
    })()

    You can use the colors code you prefer.

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Color based on Calculated Result’ is closed to new replies.