Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculators

Status
Not open for further replies.

jlskm74

Technical User
Oct 1, 2003
3
US
Would any one be able to tell me how to accomplish this? I need to create a website for a mortgage company and they would like to have all of these calculators like the site listed above....Any ideas?

Thanks!
 
They use JavaScript: Here the code from the Loan Calculator


<head><title>First Choice Quick Loan Calculator</title>
<style type=&quot;text/css&quot;>
@import url(../includes/style.css) screen;
body,td {font-family:Tahoma; font-size:12px;}
</style>
</head>
<body bgcolor=&quot;#DDDDDD&quot;>
<!--
This is an HTML form that allows the user to enter data, and allows
JavaScript to display the results it computes back to the user. The
form elements are embedded in a table to improve their appearance.
The form itself is given the name &quot;loandata&quot;, and the fields within
the form are given names like &quot;interest&quot; and &quot;years&quot;. These
fieldnames are used in the JavaScript code that follows the form.
Note that some of the form elements define &quot;onchange&quot; or &quot;onclick&quot;
event handlers. These specify strings of JavaScript code to be
executed when the user enters data or clicks on a button.
-->
<B><FONT SIZE=&quot;3&quot;>First Choice Loan Calculator</FONT></B><br>
<TABLE height=&quot;90%&quot; width=&quot;100%&quot; cellpadding=0 cellspacing=0>
<TR valign=center>
<TD align=center>
<form name=&quot;loandata&quot;>
<table>
<tr><td colspan=&quot;3&quot;><b>Enter Loan Information:</b></td></tr>
<tr>
<td>1)</td>
<td>Amount of the loan (any currency):</td>

<td><input type=&quot;text&quot; name=&quot;principal&quot; size=&quot;12&quot;
onchange=&quot;calculate();&quot;></td>
</tr>
<tr>
<td>2)</td>
<td>Annual percentage rate of interest:</td>
<td><input type=&quot;text&quot; name=&quot;interest&quot; size=&quot;12&quot;
onchange=&quot;calculate();&quot;></td>
</tr>
<tr>

<td>3)</td>
<td>Repayment period in years:</td>
<td><input type=&quot;text&quot; name=&quot;years&quot; size=&quot;12&quot;
onchange=&quot;calculate();&quot;></td>
</tr>
<tr><td colspan=&quot;3&quot; align=center>
<BR>
<input type=&quot;button&quot; value=&quot;Compute Payments&quot; onclick=&quot;calculate();&quot; style=&quot;color:#000000;font-face:Tahoma,Arial; font-size:10px; border-color:#A9BCA0;border-width:2px;background-color:#FFDC74;text-align:center;&quot;>
<BR><BR>
</td></tr>
<tr><td colspan=&quot;3&quot;>

<b>Payment Information:</b>
</td></tr>
<tr>
<td>4)</td>
<td>Your monthly payment will be:</td>
<td><input type=&quot;text&quot; name=&quot;payment&quot; size=&quot;12&quot;></td>
</tr>

<!-- <tr>
<td>5)</td>
<td>Your total payment will be:</td>
<td><input type=&quot;text&quot; name=&quot;total&quot; size=&quot;12&quot;></td>
</tr>
<tr>
<td>6)</td>

<td>Your total interest payments will be:</td>
<td><input type=&quot;text&quot; name=&quot;totalinterest&quot; size=&quot;12&quot;></td>
</tr> -->
</table>
</form></TD>
</TR>
</TABLE>

<!--
This is the JavaScript program that makes the example work. Note that
this script defines the calculate() function called by the event
handlers in the form. The function refers to values in the form
fields using the names defined in the HTML code above.
-->
<script language=&quot;JavaScript&quot;>
function calculate() {
// Get the user's input from the form. Assume it is all valid.
// Convert interest from a percentage to a decimal, and convert from
// an annual rate to a monthly rate. Convert payment period in years
// to the number of monthly payments.
var principal = document.loandata.principal.value;
var interest = document.loandata.interest.value / 100 / 12;
var payments = document.loandata.years.value * 12;

// Now compute the monthly payment figure, using esoteric math.
var x = Math.pow(1 + interest, payments);
var monthly = (principal*x*interest)/(x-1);

// Check that the result is a finite number. If so, display the results
if (!isNaN(monthly) &&
(monthly != Number.POSITIVE_INFINITY) &&
(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);
}
// Otherwise, the user's input was probably invalid, so don't
// display anything.
else {
document.loandata.payment.value = &quot;&quot;;
document.loandata.total.value = &quot;&quot;;
document.loandata.totalinterest.value = &quot;&quot;;
}
}

// This simple method rounds a number to two decimal places.
function round(x) {
return Math.round(x*100)/100;
}
</script>
</body>
</html>


--------------------------------------------------------------------------------
aka.bmp
 
Thank you....May i ask how you found the code? Thanks again
 
right-click on the page (not an an image) ---> View Source

> need more info?
:: don't click HERE ::
 
How I found the code??


[lookaround]


--------------------------------------------------------------------------------
 
being facetious of course. Yes, right-click the pop-up window


--------------------------------------------------------------------------------
 
kill it before it grows!
it=post
LOL

> need more info?
:: don't click HERE ::
 
Done
Done = Last Post
:)


--------------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top