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 juros = m_rate / (oneyear * 100); var periods = m_year * oneyear; var periodpayment = ( m_loan * ( juros / ( 1 - Math.pow( (1 + juros) , (0 - periods) ) ) ) ); periods = 0 - ( Math.log( 1 - (juros * m_loan / periodpayment) ) / Math.log(1 + juros) ); var juros_total = (periodpayment * periods) - m_loan; document.getElementById('mortgagesummary').innerHTML="
Informações de pagamento:
Reembolso Mensal:  $"+Math.round(periodpayment*100)/100+"
total de juros:  $"+Math.round(juros_total*100)/100+"
"; }