Create a Monthly Auto Loan Payment Calculator in Javascript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>JavaScript - Loan Calculator</title>
<script language="JavaScript">
			function calculateLoan()
				nMon = document.form1.txtNumerOfMonths.value;
				iRate = document.form1.txtInterestRate.value;
				aFinanced = document.form1.txtAmountFinanced.value;
				mPayment = (iRate * aFinanced)/ nMon;
				alert('Your monthly payment would be $ ' + Math.round( mPayment ) );
<form name="form1">
<body bgcolor="#FFFFFF" LANGUAGE=JavaScript >
<h2 align="center" class="LabelLarge">Monthly Auto Loan Payment Calculator</h2>
  <table align="center" border="0" cellspacing="8" cellpadding="8">
      <td width="98" align="right" class="boldText"> Number of Months:</td>
      <td width="159">
       	<!-- Add a text box to capture Number of Months input-->
      	<input name="txtNumerOfMonths" type="text" size="6" maxlength="6" />
      <td align="right" class="boldText">Interest Rate:</td>
      <td> <span class="text">
        <input name="txtInterestRate" type="text" size="6" maxlength="6" />
      <td align="right" class="boldText"> Amount Financed:</td>
      	<!-- Add a text box to capture Amount Financed input-->
      	<input name="txtAmountFinanced" type="text" size="6" maxlength="6" />
      <td colspan="2" valign="top"><div align="center">
       <!-- Add a button to execute JavaScript function-->
        <input name="button" type="button" value="Calculate" onClick="calculateLoan()"/>
        <input name="reset" type="reset" />
Share Article/Example:
  • Facebook
  • Twitter
  • Digg
  • DotNetKicks
  • DZone