As Tom Cahill would require, my challenge is (according to the "three
R's")
Reproducible: if run on OS 9.x, the monthly payment does not show up in
the text box:
Recognizable: I believe the Mac OS 9.x is not getting the temp_var
value returned to the var MP to show in the form. My hypothesis is
that the problems lies in this function:
Repairable:I believe I've located the error location, but this is my
2nd day coding Javascript, so I don't know if it's repairable. Is
there a fix to this? I heard if the Number.toFixed method isn't
available on the operating system, it is possible to write that method
as a function.
Here's my code:
Thanks for your help
R's")
Reproducible: if run on OS 9.x, the monthly payment does not show up in
the text box:
Recognizable: I believe the Mac OS 9.x is not getting the temp_var
value returned to the var MP to show in the form. My hypothesis is
that the problems lies in this function:
Code:
function round_2(Number) { var temp_var = (Number.toFixed(2)) return temp_var }
2nd day coding Javascript, so I don't know if it's repairable. Is
there a fix to this? I heard if the Number.toFixed method isn't
available on the operating system, it is possible to write that method
as a function.
Here's my code:
Code:
<HTML><HEAD><TITLE>Simple Mortgage Calculator</TITLE> <script language="JavaScript"> function round_2(Number) { var temp_var = (Number.toFixed(2)) return temp_var } function find_payment(A, B, C) { var temp_var = (A * B) / (1 - Math.pow(1 + B, -C)) return temp_var } function dosum() { if(document.temps.PP.value>0) { if((document.temps.DP.value / document.temps.PP.value) <=0) {document.temps.DP.value=document.temps.PP.value/10} else if((document.temps.DP.value/document.temps.PP.value)<.1) { alert("A 10% Miminimum Down Payment Is Required.") document.temps.DP.value=document.temps.PP.value/10 } else if((document.temps.DP.value/document.temps.PP.value)>=1) { alert("Come on. If you pay for the property in full at time of purchase, you won't need a loan. Why are you looking at terms? If you are going to pay in full, call me at (800) 760-3001 and I'll give you a 5% discount on the purchase of any property on our inventory.") document.temps.DP.value=document.temps.PP.value/10 } else {document.temps.DP.value=document.temps.DP.value} if(document.temps.YR.value<=0) {document.temps.YR.value=15} else if(document.temps.YR.value>30) { alert("30 Year Is The Maximum Repayment Period.") document.temps.YR.value=30 } else {document.temps.YR.value=document.temps.YR.value} document.temps.LA.value=document.temps.PP.value-document.temps.DP.value if((document.temps.DP.value/document.temps.PP.value)<.2) {document.temps.IR.value=.09} else if((document.temps.DP.value/document.temps.PP.value)<.3) {document.temps.IR.value=.085} else {document.temps.IR.value=.08} var MP = document.temps.MP.value var LA = document.temps.LA.value var IR = document.temps.IR.value var YR = document.temps.YR.value MP=find_payment(LA,IR/12,YR*12) document.temps.AT.value=(document.temps.PP.value*.0125) document.temps.MP.value=round_2(MP) } else {alert("Please Enter A Purchase Price")} } function clearboxes() { document.temps.PP.value = ""; document.temps.DP.value = ""; document.temps.LA.value = ""; document.temps.YR.value = ""; document.temps.IR.value = ""; document.temps.MP.value = ""; document.temps.AT.value = ""; } // --> </script> </HEAD><b>Simple Mortgage Calculator</b><br> <br> <form name="temps"> Loan Details...<br><br> <u>variable price</u> <br>Purchase Price:<input NAME="PP" onfiltered="dosum()" tabindex="1" size=15 style="font-size:9pt;"> <hr width=95%><br><br> <u>terms are flexible</u> <br>Down Payment:<input NAME="DP" onfiltered="dosum()" tabindex="1" size=15 style="font-size:9pt;"> <br>Repayment Period: (Years)<input NAME="YR" onfiltered="dosum()" tabindex="2" size=15 style="font-size:9pt;"> <br> <br> Results...<br><br> <u>fixed numbers</u> <br>Monthly Payment:<input size=13 NAME="MP" style="font-size:9pt;" tabindex="8"> <br>Loan Amount:<input NAME="LA" onfiltered="dosum()" tabindex="1" size=15 style="font-size:9pt;"> <br>Interest Rate:<input size=15 style="font-size:9pt;" NAME="IR" "onfiltered="dosum()" tabindex="3"> <br>Annual County Tax:<input size=13 NAME="AT" style="font-size:9pt;" tabindex="11"> <br> <br><br><blockquote><a href="javascript:clearboxes()" width=58 height=16 border=0>Clear</a> <br><br><a href="javascript:dosum()" width=100 height=16 border=0>CALCULATE</a> </blockquote> <div align=center><font size=1>Calculations made by this tool are believed to be accurate but are not guaranteed.</font></div> </BODY></HTML>
Comment