JavaScript Mortgage Calculator Code (1)

//JavaScript Mortgage Calculator Code (1)

JavaScript Mortgage Calculator Code (1)

Part 1
Introduction – The mortgage calculator formula

When you want to build a web page that contains a mortgage calculator, using the right JavaScript mortgage calculator formula is not easy to find. First, you need the basic mortgage loan formula, and then, once you have the formula, you have to code it in JavaScript. All this is not easy, and at the same time, it’s easy once we know the loan formula… at least we think it is!

Programming JavaScript is more a behind the scene thing than up front. Your website visitors do not see what is going on behind the webpage, however it’s fascinating if you like to code. For those of you who think that the only way you can program a loan calculator is in Java, Perl or C++, well… you are wrong! A mortgage calculator can be programmed with JavaScript. If you are a web designer, webmaster, real estate agent or a JavaScript programmer looking for mortgage calculator code, keep on reading:

The core part of the calculator code is the mortgage formula:
Pay = PrValue x IntRate / (1 – (1 + IntRate)–Period)

Where Pay is the payment, PrValue the present value of the loan, IntRate the interest rate and Period, the number of years you are borrowing the money.

Knowing the mortgage formula is one thing. It’s all the other details that make it hard to do… form validation, input transformation, etc. Therefore, it’s not that easy to program a JavaScript mortgage calculator… because a lot of small details are involved.

For a very basic example of code that you can use right away, go to this JavaScript mortgage calculator page.

As I said earlier, it’s easy and at the same time it’s not easy.

It would be easy if all we had to do was to program the mortgage formula in JavaScript. Much more is involved than just the formula code. In order to code a good calculator, you also need sub-routines that validate the entered data, that show the results with the good values (2 decimal places, percent sign), etc. It’s mainly a question of interface and data validation.

By | 2017-01-24T12:19:29+00:00 April 21st|Categories: Mortgage formula|Comments Off on JavaScript Mortgage Calculator Code (1)