function cal_mortgage(mf){ var m_loan = mf.m_loan.value; m_loan=m_loan.replace(/[$\,\%\+]/g,''); var m_rate = mf.m_rate.value; m_rate=m_rate.replace(/[$\,\%\+]/g,''); var m_year = mf.m_year.value; m_year=m_year.replace(/[$\,\%\+]/g,''); var oneyear = 12; var interest = m_rate / (oneyear * 100); var periods = m_year * oneyear; var periodpayment = ( m_loan * ( interest / ( 1 - Math.pow( (1 + interest) , (0 - periods) ) ) ) ); periods = 0 - ( Math.log( 1 - (interest * m_loan / periodpayment) ) / Math.log(1 + interest) ); var interest_total = (periodpayment * periods) - m_loan; document.getElementById('mortgagesummary').innerHTML="
Payment Summary:
Monthly Payment:  $"+Math.round(periodpayment*100)/100+"
Total Interest:  $"+Math.round(interest_total*100)/100+"
"; }