//DO NOT REMOVE THIS COPYWRITE INFO! //Increase-Your-Wage Calculator //By Daniel C. Peterson //Web Winder Website Services, 1997-2006 All Rights Reserved. //Distribution, editing or reselling of this script is strictyly prohibited //without expressed written permission from Daniel C. Peterson. //For commercial grade (professional) versions of this and many other //calculators, visit http://www.webwinder.com.
function checkNumber(input, min, max, msg)
{
msg = msg + " field has invalid data: " + input.value;
var str = input.value;
for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i + 1) if ((ch < "0" || "9" < ch) && ch != '.') { alert(msg); return false; } } var num = 0 + str if (num < min || max < num) { alert(msg + " not in range [" + min + ".." + max + "]"); return false; } input.value = str; return true; } function computeField(input) { if (input.value != null && input.value.length != 0) input.value = "" + eval(input.value); computeForm(input.form); } function computeForm(form) { if ((form.payments.value == null || form.payments.value.length == 0) || (form.interest.value == null || form.interest.value.length == 0) || (form.principal.value == null || form.principal.value.length == 0)) { return; } if (!checkNumber(form.payments, 1, 480, "# of payments") || !checkNumber(form.interest, .001, 99, "Interest") || !checkNumber(form.principal, 1, 10000000, "Principal")) { form.fv.value = "Invalid"; return; } var i = form.interest.value; if (i >= 1.0) {
i = i / 100.0;
}
i /= 12;
var pow = form.principal.value;
for (var j = 0; j < form.payments.value *12; j++) pow = (pow * i) + (pow *1); form.fv.value = (pow + (form.rate.value - form.principal.value)) form.totalint.value = (form.fv.value - form.rate.value) form.comment.value = ("If you work one hour and then invest $" + form.principal.value + " of the $" + form.rate.value + " that you earned from it; into an investment that earns " + form.interest.value + "% per year; for a period of " + form.payments.value + " years, you will end up earning $" + parseInt(eval(form.totalint.value) + eval(form.rate.value),10) + " for one hour's work! So it's up to you, do you want to make $" + form.rate.value + " per hour or $" + parseInt(eval(form.totalint.value) + eval(form.rate.value),10) + " per hour?"); } function clearForm(form) { form.payments.value = ""; form.interest.value = ""; form.principal.value = ""; form.rate.value = ""; form.comment.value = ""; }