User:AtmanDave/code2
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>SouthTown Auto Mall</title> <script type="text/javascript"> <!--Hide from old browsers var scrollMsg=" ---We finance all auto loans on site!--- " var beginPos=0 function scrollingMsg() { document.msgForm.scrollingMsg.value = scrollMsg.substring(beginPos,scrollMsg.length)+scrollMsg.substring(0,beginPos) beginPos+=1 if (beginPos > scrollMsg.length) { beginPos=0 } window.setTimeout("scrollingMsg()",200) } function Calc(myform) { var loanAmount=document.LoanCalc.Amount.value var loanAmount=parseInt(loanAmount,10) if (isNaN(loanAmount) || (loanAmount<=0)) { alert("The loan amount is not a valid number!") document.LoanCalc.Amount.value=" " document.LoanCalc.Amount.focus() } else { var loanRate=document.LoanCalc.Rate.value var loanRate=parseFloat(loanRate) if (isNaN(loanRate) || (loanRate<=0)) { alert("The interest rate is not a valid number!") document.LoanCalc.Rate.value=" " document.LoanCalc.Rate.focus() } else { var loanYears=document.LoanCalc.Years.selectedIndex var loanYears=parseInt(loanYears,10) if (loanYears==0) { alert("Please select the number of years from the list and click Calculate!") document.LoanCalc.Years.focus() } else { var monthlyPmt=monthly(loanAmount),loanRate,loanYears) document.LoanCalc.Payment.value=dollarFormat(monthlyPmt.toString) } } } } function monthly (loanAmount).loanRate,loanYears) { var interestRate="loanRate/1200 var Pmts="loanYears*12 return loanAmount * (interestRate / (1 - (1 / Math.pow(1+interestRate,Pmts)))) } function dollarFormat (valuein) { var formatValue="" var formatDollars="" var decipos="valuein.indexOf(".") if (decipos==-1) decipos=valuein.length if (dollen>3) { while (dollen>0) { tempDollars="dollars.substring(dollen-3,dollen) if (tempDollars.length==3) { formatDollars=","+tempDollars+formatDollars dollen=dollen-3 } else { formatDollars=tempDollars=formatDollars dollen=0 } } if (formatDollars.substring(0,1)==",") dollars=formatDollars.substing(1,formatDollars.length) else dollars="formatDollars" } function popupAd() { open("notice.htm","noticeWin","width=470,height=280") } //--> </script> </head> <body background="bkgrndred-automall.gif" onLoad="scrollingMsg(); popUpAd()"> <div align="center"> <p align="center"> <img src="so-townlogo.gif" alt="SouthTown Auto Mall" /> </p> <form name="msgForm"> <p align="center"><input type="text" name="scrollingMsg" size="25" /></P> </form> </div> <div style="font-family:Arial, Helvetica, sans-serif"> <p align="center"><img border="0" src="redcardivider.jpg" width="502" height="22" /></p> <h3 align="center">Auto Loan Payment Calculator</h3> <form name="LoanCalc"> <table align="center" cellspacing="3"> <tr> <td width="172"> <div align="right"> <font color="#af3a4f">*</font> Amount of Loan:</div> </td> <td width="120"><input type="text" name="Amount" Size="9" /> </td> </tr> <tr> <td> <div align="right"> <font color="#af3a4f">*</font> Interest Rate (e.g. 7.9): </div> </td> <td><input type="text" name="Rate" Size="9" /> % </td> </tr> <tr> <td> <div align="right"> <font color="#af3a4f">*</font> Number of Years: </div> </td> <td> <select name="Years"> <option selected>Years</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> </select> </td> </tr> <tr> <td> <div align="right"> <input name="button" type="button" value="Calculate" onclick="Calc(LoanCalc)"/> </div> </td> <td> <input name="Reset" type="Reset" /> </td> </tr> <tr> <td> <div align="right"> <strong>Monthly Payment</strong>: </div> </td> <td><input type="text" name="Payment" value=" " size="12" /></td> </tr> </table> <p align="center"><font color="#af3a4f" size="2">* Indicates a required field.</font> </p> </form> </div> </body> </html>