• Resolved anishlj

    (@anishlj)


    Thank you for creating such an awesome plugin. i am trying to create a calculated field with following code. but its not working. please help me to find the error.

    (function(){
    var int_rate = fieldname2/100 ;
    var amt = fieldname3 ;
    int i ;
    var new_amt = amt*(1+int_rate);

    for( i = 2 ; i <= 14 ; i++ )
    {
    new_amt = new_amt*(1+int_rate);
    }
    return round(new_amt,0);
    })();

    https://www.ads-software.com/plugins/calculated-fields-form/

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

    (@codepeople)

    Hi,

    Your equation has some syntax errors, the correct would be:

    (function(){
      var int_rate = fieldname2/100;
      var amt = fieldname3;
      var new_amt = amt*(1+int_rate);
    
      for( var i = 2 ; i <= 14 ; i++ )
      {
        new_amt = new_amt*(1+int_rate);
      }
      return ROUND(new_amt);
    })()

    Best regards.

    Thread Starter anishlj

    (@anishlj)

    Thank you for very fast response. but this code is not working still..

    Thread Starter anishlj

    (@anishlj)

    hi happy to say it finally worked by making a small change
    return ROUND(new_amt);
    was changed to
    return ROUND(new_amt,0);
    thank you for awesome plugin and awesome support…

    Plugin Author codepeople

    (@codepeople)

    Hi,

    In reality the correct syntax for the ROUND operation is ROUND(X), this operation is an alias of Math.round, more information in the following link.

    https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math/round

    The second parameter is not being used.

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘What is the error in this code’ is closed to new replies.