Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to calculate "Future Value" of an investment?

Community Beginner ,
Jul 23, 2017 Jul 23, 2017

Does anyone now the javascript formula to have a form field in Adobe Acrobat Pro calculate "Future Value" given present value, years & interest?

TOPICS
Acrobat SDK and JavaScript , Windows
4.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 26, 2017 Jul 26, 2017

You are not passing the values for the parameters of the function in the function call. It looks like you are also trying to define the function when you are setting the events. value.

I would create a document level script named "FV" and place the following code into script.

function FV(rate, nper, pmt, pv, type) {

  var pow = Math.pow(1 + rate, nper),  fv;

  if (rate) {

   fv = (pmt*(1+rate*type)*(1-pow)/rate)-pv*pow;

  } else {

   fv = -1 * (pv + pmt * nper);

  }

  return fv.toFixed(2);

}

For the field

...
Translate
LEGEND ,
Jul 26, 2017 Jul 26, 2017

You are not passing the values for the parameters of the function in the function call. It looks like you are also trying to define the function when you are setting the events. value.

I would create a document level script named "FV" and place the following code into script.

function FV(rate, nper, pmt, pv, type) {

  var pow = Math.pow(1 + rate, nper),  fv;

  if (rate) {

   fv = (pmt*(1+rate*type)*(1-pow)/rate)-pv*pow;

  } else {

   fv = -1 * (pv + pmt * nper);

  }

  return fv.toFixed(2);

}

For the field calculation I would use the following code:

var a = Number(this.getField("Q1").value);  // rate;

var b = Number(this.getField("Q1Int").value); // nper;

var c = Number(this.getField("Q1Yr").value); // pmt;

var d = Number(this.getField("Q1Pmt").value); // pv;

var e = 1; // type?

event.value = FV(a, b, c, d, e);

You have not provided any information about the "type" parameter.

From your image I see you have 2 fields with the name "Q2Int" and not one field named "Q1Int". This will generate an error when you try to compute the future value for line one because you have no field named "Q1Int". This error should appear in the Acrobat JavaScript Console if you have it open to set to open upon an error.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 26, 2017 Jul 26, 2017

Mr. Gkaiseril

THANK YOU for the time you have taken to help me to help others!

THANK YOU for your kindness!

THANK YOU SIR for being so considerate!

You are a programming wizard and your answer worked perfectly--solving a riddle others could not or would not!

May the Lord richly bless you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 26, 2017 Jul 26, 2017

Hmm, I did a text search to double check but I may have got it wrong. Seems in this case doubly important to find the author's intention.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines