navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Free FrontPage Templates

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

ASP Mortgage APR Calculator!

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> ASP Mortgage APR Calculator!
Page: [1]
 
albano

 

Posts: 132
Joined: 11/30/2003
Status: offline

 
ASP Mortgage APR Calculator! - 10/18/2004 15:33:53   
Hi everybody! After searching everywhere I thought I can use some help. I need to know if somebody can write the ASP version of this Javascript Calculator or if someone can write the formula in ASP (APR Mortgage Calculator. Here is the code:
<html>
<head>
<title>APR Calculator</title>
</head>
<body bgcolor="#FFFFFF">
<SCRIPT>

function fixFloatFormat(input) {

	if ((input.value == 0) && (input.length == null)) {

		input.value = "0.00";

	}

	var temp = eval(input.value) + 0.005

	var cents = "" + (100 + Math.floor((temp - Math.floor(temp)) * 100));

	var dollars = "" + Math.floor(temp);

	input.value = dollars + "." + cents.substring(1,3);

	return true;

}



function calcPeriod(input) {

	var output = 12;

	if (input == 0) {

		output = 12;

	}

	return output;

}



function approxRate(loan,period,monthly) {

	var xOld=0;

	var n = period;

	var z = monthly/loan;

	var x=1.1;

	if ((eval(loan) == 0) || (eval(period) == 0) || (eval(monthly) == 0)) {

		return "0.00";

	}

	while (Math.floor((xOld-1)*10000) != Math.floor((x-1)*10000)) {

		xOld=x;

		x=xOld - ((Math.pow(xOld,n+1) - (Math.pow(xOld,n) * (z + 1)) +z) / (((n + 1) * Math.pow(xOld,n)) - (n * (z + 1) * Math.pow(xOld,n - 1))));

	}

	return (1200 * (x - 1));

}

function calcMonthlyPay(interest,loan,year,period) {

	var numerator, denominator, periods, interestRate = 0;

	var i = interest;

		if (i > 1.0) {

        	i = i * 0.01;

        }

    interestRate = i / 12;

    periods = year * calcPeriod(period);

    numerator = loan * interestRate * Math.pow(1 + interestRate, periods);

    denominator = Math.pow(1 + interestRate, periods) - 1;

    monthlypay = numerator / denominator;

	return monthlypay;

} //end calcMonthlyPay



function calcApr(form) {

	fixFloatFormat(form.loan);

	if (form.interest.value < 1.0) {

       	form.interest.value = 100 * form.interest.value;

    }


	fixFloatFormat(form.interest);

	var i = form.points.value;
	
       	i = i * 0.01;

	
	fixFloatFormat(form.points);
	fixFloatFormat(form.dpoints);

	fixFloatFormat(form.ins);

	var loan = (((form.loan.value - (form.loan.value*(form.points.value*.01)))-(form.loan.value*(form.dpoints.value*.01)) - form.costs.value) - form.ins.value);

	var period = form.years.value * calcPeriod(form.period.value);

	form.apr.value = approxRate(loan,period,calcMonthlyPay(form.interest.value,form.loan.value,form.years.value,form.period.value));

	fixFloatFormat(form.apr);

	return true;

}


 </SCRIPT>
<table border="0" cellpadding="0" cellspacing="0" width="600">
  <tr>
    <td width="573" valign="top" align="left"><font face="Arial" size="2" color="#000000">

<FORM action="" method="POST">

            <INPUT TYPE="HIDDEN" NAME="period" VALUE="12" onBlur="calcApr(this.form)">

            <font color="#000080" face="Arial" size="2">

<P><CENTER><TABLE BORDER=0 CELLSPACING=1 WIDTH=400>
   <TR>
      <TD WIDTH=150>
         <P ALIGN=RIGHT><B>Loan Balance:</B>
      </TD><TD WIDTH=10>
         <P>
      </TD><TD WIDTH=100>
         <P><INPUT TYPE="text" NAME="loan" VALUE="100000.00" onBlur="calcApr(this.form)" SIZE=10>
      
      </TD></TR>
   <TR>
      <TD WIDTH=150>
         <P ALIGN=RIGHT><B>Interest Rate:</B>
      </TD><TD WIDTH=10>
         <P>
      </TD><TD WIDTH=100>
         <P><INPUT TYPE="text" NAME="interest" VALUE="8.00" onBlur="calcApr(this.form)" SIZE=10>
      </TD></TR>
   <TR>
      <TD WIDTH=150>
         <P ALIGN=RIGHT><B>Period:</B>
      </TD><TD WIDTH=10>
         <P>
      </TD><TD WIDTH=100>
         <P><INPUT TYPE="text" NAME="years" VALUE="30" onBlur="calcApr(this.form)" SIZE=10>
      </TD></TR>
   <TR>
      <TD WIDTH=150>
         <P ALIGN=RIGHT><B>Origination Points:</B>
      </TD><TD WIDTH=10>
         <P>
      </TD><TD WIDTH=100>
         <P><INPUT TYPE="text" NAME="points" VALUE="1.00" onBlur="calcApr(this.form)" SIZE=10>
      </TD></TR>
   <tr>
      <TD WIDTH=150>
         <P ALIGN=RIGHT><B> Discount Points:</B>
      </TD><TD WIDTH=10>
         <P>
      </TD><TD WIDTH=100>
         <P><INPUT TYPE="text" NAME="dpoints" VALUE="0.00" onBlur="calcApr(this.form)" SIZE=10>
      </TD>
   </tr>
   <tr>
      <TD WIDTH=150>
         <P ALIGN=RIGHT><b>Closing Costs:</b>
      </TD><TD WIDTH=10>
         <P>
      </TD><TD WIDTH=100>
         <P><INPUT TYPE="text" NAME="costs" VALUE="1200" onBlur="calcApr(this.form)" SIZE=10>
      </TD>
   </tr>
   <TR>
      <TD WIDTH=150>
         <P ALIGN=RIGHT><B>Mortgage Ins:</B>
      </TD><TD WIDTH=10>
         <P>
      </TD><TD WIDTH=100>
         <P><INPUT TYPE="text" NAME="ins" VALUE="0.00" onBlur="calcApr(this.form)" SIZE=10>
      </TD></TR>
   <TR>
      <TD WIDTH=150>
         <P ALIGN=RIGHT><B>APR:</B>
      </TD><TD WIDTH=10>
         <P>
      </TD><TD WIDTH=100>
         <P><INPUT TYPE="text" NAME="apr" VALUE="0.00" onBlur="calcApr(this.form)" SIZE=10>
      </TD></TR>
</TABLE></CENTER>

      </font>

</FORM>       
    </td>
  </tr>
 
</table>  </body></html>
and here is the link to the calculator: http://truelending.com/apr_calculator.htm

_____________________________

Mortgage Site Link Exhange | http://www.truelending.com
Page:   [1]

All Forums >> Web Development >> ASP and Database >> ASP Mortgage APR Calculator!
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts