Skip to content

Basic Loan Calculator

James Pederson edited this page May 17, 2014 · 1 revision

Basic Implementation

Basic mode grabs three values from the form, and returns general information about a loan. The available pieces of information are loan amount, total payments, total interest, and monthly payment amount. This is the default mode used by accrue.js. If you haven't specified your own fields, it will add the three required fields into the div for you.

$(".calculator-loan").accrue();

Formatting Output

You can change the way that accrue outputs the results from this by passing some plugin options into the function.

$(".calculator-loan").accrue({

  // set the output element
  response_output_div: ".results",

  // set the response format
  response_basic: 
    '<p><strong>Monthly Payment:</strong><br>$%payment_amount%</p>'+
    '<p><strong>Number of Payments:</strong><br>%num_payments%</p>'+
    '<p><strong>Total Payments:</strong><br>$%total_payments%</p>'+
    '<p><strong>Total Interest:</strong><br>$%total_interest%</p>',

  // set error text for when one of the fields is empty or invalid.
  error_text: "Please fill in all fields."

});

See the plugin options to find out more about how to customize the output or change other settings.