Use JavaScript to find out just how much that new house or car is going to cost you each month. Enter values into the fields below to find out how much each monthly payment would be with the given number of payments, interest rate, and loan amount.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | /******************************************************* * MYCPLUS Sample Code - https://www.mycplus.com * * * * This code is made available as a service to our * * visitors and is provided strictly for the * * purpose of illustration. * * * * Please direct all inquiries to saqib at mycplus.com * *******************************************************/ <!-- TWO STEPS TO INSTALL INTEREST CALCULATOR: 1. Paste the coding into the HEAD of your HTML document 2. Copy the last code into the BODY of your HTML document --> <!-- STEP ONE: Copy this code into your HTML document --> <head> <script LANGUAGE="JavaScript"> <!--Total Java Scripts 99 - Next Step Software--> <!-- Begin 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 = parseFloat(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, 100, 10000000, "Principal")) { form.payment.value = "Invalid"; return; } var i = form.interest.value; if (i > 1.0) { i = i / 100.0; form.interest.value = i; } i /= 12; var pow = 1; for (var j = 0; j < form.payments.value; j++) pow = pow * (1 + i); form.payment.value = (form.principal.value * pow * i) / (pow - 1) } function clearForm(form) { form.payments.value = ""; form.interest.value = ""; form.principal.value = ""; } // done hiding from old browsers --> </script> <!-- STEP TWO: Put this last script into the BODY of your HTML document --> <body> <center> <form method=POST> <table border> <tr> <td> <div ALIGN=CENTER> # of<br />Payments</div> </td> <td> <div ALIGN=CENTER>Interest<br />Rate</div> </td> <td> <div ALIGN=CENTER>Principal</div> </td> <td> </td> <td> <div ALIGN=CENTER> Monthly<br /> Payment</div> </td> </tr> <tr> <td> <input TYPE=TEXT NAME=payments SIZE=5 onChange=computeField(this)> </td> <td> <input TYPE=TEXT NAME=interest SIZE=6 onChange=computeField(this)> </td> <td> <input TYPE=TEXT NAME=principal SIZE=9 onChange=computeField(this)> </td> <td> </td> <td> <input TYPE=TEXT NAME=payment SIZE=9 onChange=computeField(this)> </td> <td> <input TYPE="button" VALUE="Compute" onClick=computeForm(this.form)> </td> <td> <input TYPE="reset" VALUE="Reset" onClick=clearForm(this.form)> </td> </tr> </form> <form method=POST> <tr> <td> <input TYPE=TEXT NAME=payments SIZE=5 onChange=computeField(this)> </td> <td> <input TYPE=TEXT NAME=interest SIZE=6 onChange=computeField(this)> </td> <td> <input TYPE=TEXT NAME=principal SIZE=9 onChange=computeField(this)> </td> <td> </td> <td> <input TYPE=TEXT NAME=payment SIZE=9 onChange=computeField(this)> </td> <td> <input TYPE="button" VALUE="Compute" onClick=computeForm(this.form)> </td> <td> <input TYPE="reset" VALUE="Reset" onClick=clearForm(this.form)> </td> </tr> </form> <form method=POST> <tr> <td> <input TYPE=TEXT NAME=payments SIZE=5 onChange=computeField(this)> </td> <td> <input TYPE=TEXT NAME=interest SIZE=6 onChange=computeField(this)> </td> <td> <input TYPE=TEXT NAME=principal SIZE=9 onChange=computeField(this)> </td> <td> </td> <td> <input TYPE=TEXT NAME=payment SIZE=9 onChange=computeField(this)> </td> <td> <input TYPE="button" VALUE="Compute" onClick=computeForm(this.form)> </td> <td> <input TYPE="reset" VALUE="Reset" onClick=clearForm(this.form)> </td> </tr> </table> </form> </center> <!-- Script Size: 3.93 KB --> |