• Resolved Damn!

    (@greedymind)


    Hello,

    I tried to change the color of a calculated field’s output with this code

    (function(){
    var v =fieldname8+fieldname9+fieldname10, e = jQuery('#my-total-percentage');
    
    if(v > 100) color = 'red';
    if(v == 100) color = '#0DD13E';
    if(v < 100) color = 'orange';
    
    return e.css('color',color).html('~'+v+'%');
    })()

    but it returns [object Object] as output. What is the issue here.

    Also how do I prevent the mouse cursor from changing into “Text select” when hovered over a read-only calculated field?

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello,

    First, if the id of your field is: my-total-percentage (with hyphens), the correct selector would be:

    e = jQuery('[id="my-total-percentage"]');

    And finally, the return of the equation should be the calculated value, or the HTML content of the field, as follows:

    (function(){
    var v =fieldname8+fieldname9+fieldname10, e = jQuery('[id="my-total-percentage"]');
    
    if(v > 100) color = 'red';
    if(v == 100) color = '#0DD13E';
    if(v < 100) color = 'orange';
    e.css('color',color).html('~'+v+'%');
    return v;
    })()

    or

    (function(){
    var v =fieldname8+fieldname9+fieldname10, e = jQuery('[id="my-total-percentage"]');
    
    if(v > 100) color = 'red';
    if(v == 100) color = '#0DD13E';
    if(v < 100) color = 'orange';
    e.css('color',color).html('~'+v+'%');
    return e.html();
    })()

    Depending if you want return only the number or the formatted text.

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Calculated Field output text color’ is closed to new replies.