• Resolved dov777

    (@dov777)


    Hello this really is a fantastic calculator thankyou.

    If my end calculation is over a certain amount, in this case 3,000,000 how could I replace the number with a 0 and display underneath a text message in a html field please?

    I’m assuming you would use a html field with hide in the css, but perhaps there is another way of doing this I’m stuck on this.
    Thanks for any help

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

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

    (@codepeople)

    Hello @dov777

    I’ll try to describe the process with a hypothetical example. Assuming the current equation is: fieldname1+fieldname2

    It can be edited as follows:

    
    (function(){
    var result = fieldname1+fieldname2;'
    if(result<=3000000) return result;
    return 0;
    })()
    

    And then you can define a dependency in the settings of the calculated field to display the “HTML Content” field if the equation’s result is zero.

    More information about dependencies by reading the following post in the plugin’s blog:

    https://cff.dwbooster.com/blog/2020/03/01/dependencies/

    Best regards.

    Thread Starter dov777

    (@dov777)

    Thank you so much your support and calculator its amazing.

    I have done this successfully but as the calculations shown are irrelevant when the final calculation is greater than 3M, I am trying to hide the calculations aswell. I tried nesting if statements to display 0 in previous fields but as the final calculation depends on previous fields that doesn’t work.

    So I am just trying to hide the text inside the field with css if that’s possible. My css (which is wrong obviously) looks something like this:

    #fbuilder .hide-two .cff-calculated-field input[type=”number”] {display:none;}

    Then I have an auxiliary calculated field with this:
    jQuery(‘.exceeded’)[IF(fieldname31 ==’0′, ‘addClass’, ‘removeClass’)](‘hide-two’);

    With exceeded hide-two in the css of the calculated fields I’d like to hide. I don’t want to hide the whole box just the number.

    Plugin Author codepeople

    (@codepeople)

    Hello @dov777

    You can hide the input tag from the same equation, you don’t need another calculated field as an auxiliary.

    For example, assuming you have the equation: fieldname1+fieldname2 and the current calculated field has the name: fieldname56. In the next equation, I will get the field’s object with the getField operation, I’ll call its method jQueryRef to get the jQuery object of the field. And finally, I’ll show/hide its input tag:

    
    (function(){
    var result = fieldname1+fieldname2, 
        input = getField(56).jQueryRef().find('input');
    
    if(3000000 < result) input.hide();
    else input.show();
    
    return result;
    })()
    

    If yo want force the result to zero if its greater than 3000000, the previous equation should be edited as follows:

    
    (function(){
    var result = fieldname1+fieldname2, 
        input = getField(56).jQueryRef().find('input');
    
    if(3000000 < result){ input.hide(); result = 0;}
    else input.show();
    
    return result;
    })()
    

    Best regards.

    Thread Starter dov777

    (@dov777)

    Thank you for this, the getField has a lot of possibilities.
    All the best.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘If a calculation is over a certain amount, how to display a message instead’ is closed to new replies.