How to calculate "Future Value" of an investment?
Does anyone now the javascript formula to have a form field in Adobe Acrobat Pro calculate "Future Value" given present value, years & interest?
Does anyone now the javascript formula to have a form field in Adobe Acrobat Pro calculate "Future Value" given present value, years & interest?
I have a very basic understanding, and have written the formulas for a hundred other basic calcs in the form; but this FV is kicking my rear...therefore, I will spend some more time in the link you gave to me...thank you. Here is my latest attempt to adapt the script to my form fields, but it doesn't work. I am sure part of the problem is that I don't have variables for pmt or type. I don't even know what "type" is to the equation. I don't need "pmt" so I tried removing both of them, but that didn't work either. I am sorry to be so much trouble. Thank you for any help you can provide.
var a = Number(this.getField("Q1").value);
var b = Number(this.getField("Q1Int").value);
var c = Number(this.getField("Q1Yr").value);
var d = Number(this.getField("Q1Pmt").value);
event.value = 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);
}
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.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.