Support » Plugin: Calculated Fields Form » Leave calculated field bank if value is zero

  • Resolved kiwibrit

    (@kiwibrit)


    I am running WordPress 4.9.8, Calculated Fields Form Version 1.0.258. Browsers: Safari 12.0, Chrome Version 69.0.3497.100 (Official Build) (64-bit)

    I am a CFF newb.

    Looking at the Imperial measures version as an example, once the Length and Width dimensions have been completed, the Density (calculated) field shows as zero, then shows the correct figure the Weight value has been entered. I would like that field to remain blank until the Weight field has been given a value. I tried hiding the present Density field (fieldname7) and setting up a seen calculated field with the following code:

    (function(){
    
    if(fieldname7 > 0) return ();
    
    })();

    It didn’t work – the field remained blank even after a weight value had been entered. I have read this thread but did not quite understand what I was reading, and how to relate it to my problem.

    The calculated (Density) (fieldname7) set equation is

    ((fieldname6)/16)/(((fieldname2)/12)*((fieldname5)/12)*((fieldname8)/12))

    if that value is zero, I would be grateful for advice on how to leave a displayed field blank

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @kiwibrit,

    The solution in this case can be implemented as follows:

    
    (function(){
    var result = (fieldname6/16)/((fieldname2/12)*(fieldname5/12)*(fieldname8/12));
    return IF(result, result, '');
    })()
    

    and that’s all.

    kiwibrit

    (@kiwibrit)

    Gosh, that was a quick response. It works, thank you.

    Plugin Author codepeople

    (@codepeople)

    Hello @kiwibrit,

    It has been a pleasure.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Leave calculated field bank if value is zero’ is closed to new replies.