Script Categories













Calculators >>> Savings Estimator.

Enter how much you can afford to save each month, how long you can save this amount, and the interest rate you can get on your savings and this script will display your total savings.

Total invested each month:
Number of months/years to aquire sum:
Interest rate on savings: %
Total :

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
var i = 0; // interest
var m = 0; // months
var f = 0; // factor
var den = 0;
var s = "0"; // string
var d = 0; // decimal place
function CalcA() {
if(document.calform.interest.value=="" || document.calform.months.value=="" || document.calform.payment.value=="") {
alert("Please fill in all of the required fields.");
}
else {
if(document.calform.period.options[1].selected == true) {
m = document.calform.months.value * 12;
}
else {
m = document.calform.months.value;
}
i = Math.pow(((document.calform.interest.value/100)+1),.0833333)-1;
den = i / (i+1);
f = Math.pow((i+1),m)-1;
f /= den;
f *= document.calform.payment.value;
d = String(f).indexOf(".");
s = String(f).substring(0,(d+3));
document.calform.total.value = "$" + s;
   }
}
//  End -->
</script>
<form method=post name="calform">
<table width=400>
<tr>
<td
align=right width=200>Total invested each month:</td>
<td>
<input type=text name=payment size=13 maxlength=13></td>
</tr>
<tr>
<td
align=right width=200>Number of months/years to aquire sum:</td>
<td>
<input type=text name=months size=3 maxlength=3>
<select
name=period size=1>
<option
value="m">Months
<option value="y">Years
</select>
</td>
</tr>
<tr>
<td
align=right width=200>Interest rate on savings:</td>
<td>
<input type=text name=interest size=5 maxlength=5><b> %</b></td>
</tr>
<tr>
<td
width=200 colspan=2 align=center>
<input type=button name=button1 value="How much will I have?" onClick="javascript:CalcA()"></td>
</tr>
<tr>
<td
colspan=2 align=center width=200 nowrap>Total :
<input type=text name=total value="0.00" size=15 maxlength=15></td>
</tr>
</table>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

R7


©