Copy link to clipboard
Copied
Does anyone now the javascript formula to have a form field in Adobe Acrobat Pro calculate "Future Value" given present value, years & interest?
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now