PeopleSoft Adoption Made Smooth & Simple!
On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool. Claim Your Free WalkMe Account Now
Become a Premium Member and unlock a new, free course in leading technologies each month.
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
<script language="javascript">
function recalcapr(loantype, loanid)
{
if (document.forms.form1.aprtype.value=='Automatic')
{
if (document.forms.form1['intonly'+loanid].value=='1') var io=true;
else var io=false;
if (loantype=='c')
{
var rate=document.forms.form1['loan'+loanid+'conforming'].value;
document.forms.form1['loan'+loanid+loantype+'apr'].value=calc_apr(document.forms.form1.othercost_con.value, rate, document.forms.form1['loan'+loanid+'term'].value, io, document.forms.form1.loanamt_con.value);
}
else
{
var rate=document.forms.form1['loan'+loanid+'jumbo'].value;
document.forms.form1['loan'+loanid+loantype+'apr'].value=calc_apr(document.forms.form1.othercost_jum.value, rate, document.forms.form1['loan'+loanid+'term'].value, io, document.forms.form1.loanamt_jum.value);
}
}
}
function calc_apr(extracosts, rate,term, io,loanamount){
var apr=0;
var total=parseFloat(loanamount)+parseFloat(extracosts);
var P=calc_payment(total, rate, term, io);
rate=rate/1200;
//alert (P);
var apr_next=rate;
var my_range_top=.00000005;
var message='';
var i=0;
//Newton-Raphson method
while ((apr_next>apr+my_range_top)||(apr_next<apr)) {
apr=apr_next;
apr_next=P/loanamount*(Math.pow(1+parseFloat(apr),term)-1)/(Math.pow(1+parseFloat(apr),term));
}
return (apr*1200).toFixed(3);
}
function calc_apr_payment(costs, rate, term, io){
var apr_payment=calc_payment(costs, rate, term);
return apr_payment;
}
function calc_payment(amount, rate, term, io){
r=rate/100/12;
r1=r+1;
t1=Math.pow(r1,term);
payment=t1/(t1-1)*r*amount;
return payment;
}
</script>
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.