• Resolved kurkovnick

    (@kurkovnick)


    I am trying to create code that shows a field only on certain conditions after the field calculation is performed. For example if adding 2 fields before it results in less then a certain amount, then not to show the field.

    I tried using document.queryselector but in the console it shows that my selector: ‘div.fieldname28_1’ is invalid because it is now div ‘div.(0)_1’ and it’s an invalid selector.

    Here is my code in the field that is not working:

    (function(){
    function removeField(){
    document.querySelector(‘div.fieldname28_1’).setAttribute(“style”, “display : none”);
    }

    let p = CEIL(fieldname4 * 0);
    if (fieldname4 == “” || fieldname4 == null) return “Please Enter Value in the <Approximate Lineal Ft>”;
    else if(p <= 0) removeField();
    else return p;
    })();

    You can test it by going to the address where the plugin is installed. Enter 100 into the approximate linear feet. Select the Horizontal fence style. Select the 1×5.5×6 board size.

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

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

    (@codepeople)

    Hello @kurkovnick

    Thank you very much for using our plugin. You have some alternatives to implement the behavior described.

    You can configure a dependency between the equation’s results and the field to show/hide from the settings of the calculated field:

    “If the value is greater than 0 then show the fieldname28 field”

    Learn more about dependencies by reading the following blog post:

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

    In this case, the equation would be simply:

    IF(0 < fieldname4, CEIL(fieldname4), '')

    Note that let p = CEIL(fieldname4 * 0); has no sense because it would be always zero.

    Another alternative would be to ignore/activate the field as part of the equation instead of using dependencies. In this case, the equation can be implemented as follows:

    
    (function(){
        if(0 < fieldname4) { 
            ACTIVATEFIELD(fieldname28|n); 
            return CEIL(fieldname4);
        } else {
            IGNOREFIELD(fieldname28|n); 
            return '';
        }
    })()

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘How to make the field disappear if the calculation turns out to be 0?’ is closed to new replies.