html - JavaScript: ReferenceError: homeLoanForm is not defined -


i'm working on homework lot of predefined code. when run code, far, firebug throws "referenceerror: homeloanform not defined." i'm not sure what's going on, since didn't write of code.

<!doctype html>       <html>     <head>     <meta charset="utf-8">      <title>chapter 10 shoreline state bank</title>     <script type="text/javascript">     <!-- hide old browsers -->     var admsg = " ** did know used cars can have 100% loan value? ask details! ** "     var beginpos = 0     function scrollingmsg() {         msgform.scrollingmsg.value = admsg.substring(beginpos, admsg.length)+admsg.substring(0, beginpos)         beginpos=beginpos+1         if (beginpos>admsg.length) {             beginpos=0         }         window.settimeout("scrollingmsg()",200)     }      var salesamt     var loanamt     var loanrate     var loanyears      function validsalesamt() {         var salesamt=parseint(homeloanform.saleamount.value,10)         if (isnan(salesamt) || (salesamt <= 0)) {             alert("the sales price not valid number!")             homeloanform.saleamount.value = ""             homeloanform.saleamount.focus()         }         else {             var downpmtamt=parseint(homeloanform.downpayment.value,10)             if (isnan(downpmtamt) || (downpmtamt <= 0) || (downpmtamt > salesamt)) {                 alert("the down payment should greater 0 , less sales amount!")                 homeloanform.downpayment.value = ""                 homeloanform.downpayment.focus()             }             else{                 loanamt = salesamt-downpmtamt                 homeloanform.loanamount.value = loanamt                 homeloanform.rate.focus()             }         }     }      function calcloanamt() {         loanrate=parsefloat(homeloanform.rate.value)         if (isnan(loanrate) || (loanrate <= 0)) {             alert("the interest rate not valid number!")             homeloanform.rate.value = ""             homeloanform.rate.focus()         }         else {             loanyears=homeloanform.years.value             if  (isnan(loanyears) || (loanyears < 1 || loanyears > 30)) {                 alert("please select valid number list (10, 15, 20, or 30)!")                 homeloanform.years.selectedindex = 0                 homeloanform.years.focus()             }         }     }      //-->     </script>     <style type="text/css">     <!--     .align-center {         text-align:center;     }      table {         margin-left: auto;         margin-right: auto;         width: 70%;     }      .block {         width: 50%;         margin-right: auto;         margin-left: auto;     }      .center-div {         width: 70%;         margin-right: auto;         margin-left: auto;     }      .header-text {         font-family: arial, helvetica, sans-serif;         font-size: 12pt;         font-weight: bold;         text-align: center;     }      .center-items {         text-align: center;     }      .right-align {         text-align: right;         width: 50%;     }      .left-align {         text-align: left;         width: 50%;     }      #displaydatelast {         text-align: left;         width: 50%;         margin-right: auto;         margin-left: auto;     }      -->     </style>     </head>     <body onload="scrollingmsg();">     <div class="center-div">       <p class="center-items"><img src="chapter10-1banner.jpg" alt="banner" /></p>     </div>     <div class="center-div">     <form id="msgform">         <p style="text-align: center;"><input type="text" name="scrollingmsg" size="25" /></p>     </p>     </div>     <p style="text-align:center; font-size:16; font-weight:bold;">home mortgage loan payment calculator</p>     <p class="block"><strong>directions: </strong>enter agreed selling price, press tab key, enter down payment , press tab key. loan amount calculated automatically. enter interest rate , number of years loan , click calculate button.</p>     <div class="center-div">     <form id="homeloanform" method="post">       <table>             <tr>                <td class="right-align">                   <span style="color:#cc0000;">*</span>sales price:                </td>                <td class="align-left"><input type="text" name="saleamount" size="9" /></td>             </tr>             <tr>               <td class="right-align">                  <span style="color:#cc0000;">*</span>down payment in dollars               </td>               <td class="align-left"><input name="downpayment" type="text" id="downpayment" size="9" onblur="validsalesamt()" /></td>             </tr>             <tr>               <td class="right-align">                  <span style="color:#cc0000;">*</span>loan amount               </td>                  <td class="align-left"><input name="loanamount" type="text" id="loanamount" size="9" />                         </td>             </tr>             <tr>                <td class="right-align">                   <span style="color:#cc0000;">*</span>interest rate (e.g. 5.9):               </td>                <td class="align-left"><input name="rate" type="text" id="rate" size="5" maxlength="5" />                 </td>             </tr>             <tr>                <td class="right-align">                   <span style="color:#cc0000;">*</span>number of years:                </td>                <td><select name="years" id="years">                  <option value="0">select number of years</option>                  <option value=10>10</option>                  <option value=15>15</option>                  <option value=20>20</option>                  <option value=30>30</option>                </select></td>            </tr>             <tr>                <td class="right-align">                  <input name="button" type="button" value="calculate" onclick="calcloanamt()" />                </td>                <td class="align-left">                  <input name="reset" type="reset" />                </td>             </tr>             <tr>                <td class="right-align">                   <span style="font-weight:bolder;">monthly payment:</span>                </td>                <td><input type="text" name="payment" id="payment" value=" " size="12" /></td>             </tr>             <tr>               <td colspan="2" class="align-center">                  <span style="color:#cc0000; font-size:12px;">* indicates required field.</span>               </td>             </tr>       </table>     </form>     </div>      </body>     </html> 

well, never defined variable homeloanform in code.

assuming should refer form same id, make sure define before using it, e.g.:

var homeloanform = document.getelementbyid('homeloanform'); 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -