free hosting   image hosting   hosting reseller   online album   e-shop   famous people 
Free Website Templates
Free Installer

Loan Calculator


This script lets you create a loan comparison table.

The results will be a close approximation of actual loan repayments you can expect from a financial institution.


Unfortunately, the original script from Website Abstraction doesn't format the output as dollars and cents.

So I added the Number to Currency Convertor.


Paste the code below in the head section of your page:
Now paste this in the body section:

How It Works

The calculator is contained within a form named calc.

Each input box has its own name:
  • loan for the loan amount
  • months for the number of months
  • rate for the interest rate
  • pay for the final result
  • The pay box is set to read-only, to prevent any attempt at user input.


    Clicking the Calculate button calls the function showpay().

    First, this checks to see that all input values are valid:
    if ((document.calc.loan.value == null
    || document.calc.loan.value.length == 0)
    || (document.calc.months.value == null
    || document.calc.months.value.length == 0)
    || (document.calc.rate.value == null
    || document.calc.rate.value.length == 0))

    { document.calc.pay.value = "Incomplete data";
    If not, an Incomplete data message appears in the result box.

    Otherwise, the input values are processed:
    var princ = document.calc.loan.value;
    var term = document.calc.months.value;
    var intr = document.calc.rate.value / 1200;
    Note : the rate value is divided by 1200 to convert to a monthly interest value.


    Next, the monthly payment value is computed, then output as dollars and cents:
    var currency = formatCurrency(princ * intr / (1 - (Math.pow(1/(1 + intr), term))));
    document.calc.pay.value = currency;


    Try It Out

    Simply enter the appropriate values and click the Calculate button.

    Clicking the Reset button will clear the form.

    Parameter Your Data
    Loan Amount
    Loan Length in Months
    Interest Rate
    Estimated
    Monthly Payment :
    Enter only numeric values - no commas
    Use decimal points where needed
    Non-numeric values will cause errors


    © 2001 CyberSchool