Skip to main content
Participant
January 19, 2017
Question

Custom calculations for mortgage rates on form

  • January 19, 2017
  • 1 reply
  • 520 views

Working on a PDF form for a client that has a few fillable fields and the rest are auto calculated based off those entries. Calculating the down payment and loan amount based off the purchase price was easy, but I can't figure out the auto calculated APR and P&I based off the rate they input.

This is the formula from an Excel file they gave me for the 30 year P&I (I replaced the cells callouts with what I have the fields labeled—PurchasePrice & ThirtyYearRate).

=PurchasePrice*(((ThirtyYearRate*0.01/12)*(1+(ThirtyYearRate*0.01/12))^360)/((1+ ThirtyYearRate*0.01/12)^360-1))

After I get the P&I figured out, the APR field will be based off the P&I.

I've tried to do some reading online, but Javascript is above me. Any help would be greatly appreciated.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 19, 2017

JS isn't really that hard. All the operators you used in your formula (except for one) can be used in JS directly to perform calculations.

The only one you need to replace is the power operator ("^"). To do that in JS you need to use the built-in Math.pow command, like so:

2^6 = Math.pow(2,6)

So you just need to access the fields' values, save them into variables, write your formula and at the end apply the result to event.value.

stbartelsAuthor
Participant
January 19, 2017

Thanks for the response.

I did read about the Math.pow, but don't understand how it would be formatted in this instance since the 2 (in your example) is an unknown number in this formula.

(ThirtyYearRate*0.01/12)*(1+(ThirtyYearRate*0.01/12))^360

try67
Community Expert
Community Expert
January 19, 2017

Instead of numbers you can use variables. For example:

var a = 2;

var b = 6;

var c = Math.pow(a,b);

The value of c will be 64.

On Thu, Jan 19, 2017 at 10:48 PM, ThirtyTenDesigns <forums_noreply@adobe.com