• Resolved Moiqc

    (@moiqc)


    Hi,

    I know that we cann use functions in the calculated field, and I’ve been able to use it.

    (function(){
    var variable = 0;
    return variable;
    });

    Now, to have a clearer code, I thought I could use many functions, Java script-like.

    function1 myFct() {
    return 4;
    }

    function2 myFct2() {
    return 6;
    }

    myFct() + myFct2();

    But that code doesn’t work. Is there a way to do that? Thank you very much!!

    https://ww.wp.xz.cn/plugins/calculated-fields-form/

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

    (@codepeople)

    Hi,

    Could you send me exactly the code you are using, please?

    Best regards.

    Thread Starter Moiqc

    (@moiqc)

    I tried many things, but now I just tried again with:

    function myFct(){
    var variable = 0;
    variable = 1000;
    return variable;
    }

    function myFct2(){
    var variable =0;
    variable = 10000;
    return variable;
    }

    myFct1() + myFct2();

    and it didn’t work. However, I just thought that I could use hidden calculted fields and take their answer. If you see a better idea, I’m still open to suggestions.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    If you are creating the functions inside an equation, the correct format would be:
    (function(){

    function myFct(){
    var variable = 0;
    variable = 1000;
    return variable;
    };

    function myFct2(){
    var variable =0;
    variable = 10000;
    return variable;
    };

    return myFct1() + myFct2();
    })()

    Another solution is define the functions in a separated javascript file.

    Best regards.

    Thread Starter Moiqc

    (@moiqc)

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Many functions’ is closed to new replies.