Javascript Loan Calculator
<p>When I run the following code in Chrome, it tells me that <code>calculate</code> is not defined. The code is meant to be a loan calculator.                                                              </p>

<pre><code>   &lt;!--DOCTYPE html--&gt; 
     &lt;form name="loandata"&gt;
    &lt;table&gt;
        &lt;tr&gt;&lt;td colspan=3&gt;&lt;h1&gt;&lt;b&gt;Enter Loan Information&lt;/b&gt;&lt;/h1&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;1)&lt;/td&gt;
            &lt;td&gt;Amount of the loan (any currency):&lt;/td&gt;
            &lt;td&gt;&lt;input type=text name=principal size=12 onChange="calculate()"&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;2)&lt;/td&gt;
            &lt;td&gt;Annual percentage rate of interest&lt;/td&gt;
            &lt;td&gt;&lt;input type=text name=interest size=12 onChange="calculate()"&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;3)&lt;/td&gt;
            &lt;td&gt;Repayment period in years:&lt;/td&gt;
            &lt;td&gt;&lt;input type=text name=years size=12 onChange="calculate()"&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tr&gt;
    &lt;tr&gt;&lt;td colspan=3&gt;
        &lt;h1&gt;&lt;b&gt;
            &lt;input type=button value="Compute" onClick="calculate()"&gt;
            Payment Information
        &lt;/h1&gt;&lt;/b&gt; 
    &lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;4)&lt;/td&gt;
        &lt;td&gt;Your monthly payment:&lt;/td&gt;
        &lt;td&gt;&lt;input type=text name=total interest size=12&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/form&gt;
    &lt;script type="text/javascript"&gt;
    function calculate(){
        var principal= document.loandata.principal.value; //Get the input principal amount
        var interest = document.loandata.interest.value/100/12; //Get the input interest amnount 
        var payments= document.loandata.years.value*12; //get the number of years to payback the loan
        var y =math.pow(1+ interest, payments);
        var monthly = (principal*y*interest)/(y-1);
        if(!isNaN(monthly) &amp;&amp;
            (monthly 1= Number.POSITIVE_INFINITY)&amp;&amp;
            (monthly != Number.NEGATIVE_INFINITY){
                document.loandata.payment.value =round(monthly);
                    document.loandata.total.value= round(monthly*payments);
                    document.loandata.totalinterest.value=
                    round(*(monthly*payments)-principal);
                }
            }
            function round(y){
                return Math.round(y*100)/100;
            }
    &lt;/script&gt;
</code></pre>