Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7162253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:42:15+00:00 2026-05-28T13:42:15+00:00

This is my first week teaching myself javascript and i have run into a

  • 0

This is my first week teaching myself javascript and i have run into a problem.

I am trying to create a simple mortgage ‘loan to value’ calculator. My calculator works fine but I am trying to set up a minimum value validation for one of my two form fields.

Here is a link to the page

Link

My code is below

function calculate (form) {
    var propVal = form.propertyValue.value; var loanAmt =
    form.mortgageAmount.value; var type = form.mortgageType.value;

    var ltv = loanAmt / propVal * 100 ;

    var roundedLtv = Math.floor(ltv);

    if ( type === "First Time Buyer" && roundedLtv <= 91 )  {   
        document.getElementById("result").innerHTML= ("Your loan to value is: <b>" + (roundedLtv) + "%</b> <br /> We can help place your mortgage");
    }
    else if ( type === "Moving Home" && roundedLtv <= 91 )  {   
        document.getElementById("result").innerHTML= ("Your loan to value is: <b>" + (roundedLtv) + "%</b> <br /> We can help place your mortgage");
    }
    else if ( type === "Remortgage" && roundedLtv <= 86 )  {    
        document.getElementById("result").innerHTML= ("Your loan to value is: <b>" + (roundedLtv) + "%</b> <br /> We can help place your mortgage");
    }
    else if ( type === "Buy To Let Purchase" && roundedLtv <= 81 )  {   
        document.getElementById("result").innerHTML= ("Your loan to value is: <b>" + (roundedLtv) + "%</b> <br /> We can help place your mortgage");
    }
    else if ( type === "Buy To Let Remortgage" && roundedLtv <= 76 )  {     
        document.getElementById("result").innerHTML= ("Your loan to value is: <b>" + (roundedLtv) + "%</b> <br /> We can help place your mortgage");   
    }
    else 
    {       
        document.getElementById("result").innerHTML= ("Your loan to value is: <b>" + (roundedLtv) + "%</b> <br /> Unfortunatly we cannot help you place a mortgage");    
    }
}

All works ok until this point, where i am trying to alert the user that the loan amount needs to be larger than 45000. Below in the HTML you will see im am trying to use the onBlur function

function loancheck (propVal,loanAmt,form) {      
    if (loanAmt >= 45000) {
        document.getElementById("val1").innerHTML= ("Thank You"); 
    }
    else   
    {       
         document.getElementById("val1").innerHTML= ("Higher");   
    }
} 

This is the html to go with it

<form name="myform" ACTION="" METHOD="GET"> Mortgage Type 
    <select name="mortgageType"> 
        <option>First Time Buyer</option> 
        <option>Moving Home</option> 
        <option>Remortgage</option> 
        <option>Buy To Let Purchase</option> 
        <option>Buy To Let Remortgage</option> 
     </select> 

     <br /> 
     Value <input name="propertyValue" type="text" value=""/><br />

     Mortgage Amount <input name="mortgageAmount" type="text" value="" onBlur="loancheck(this.value)" />

     <p id="val1"></p>

     <INPUT TYPE="button" NAME="button" Value="Click" onClick="calculate(this.form)">
</form> 

<br /><br /> 
<p id="result"> </p>

Im sure I’m doing something fundamentally wrong but if someone could point it out to me i would be most thankful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:42:16+00:00Added an answer on May 28, 2026 at 1:42 pm

    When loancheck is called, the variable loanAmt is undefined, because not enough parameters were passed to the function. Consider cleaning up the function definition in the following way:

    function loancheck (loanAmt) { // remove unused parameters
        var userAlert = document.getElementById("val1") // don't repeat yourself
        if (loanAmt >= 45000) { 
            userAlert.innerHTML= "Thank You"; // remove extraneous parens
        } else { 
            userAlert.innerHTML= "Higher";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am into my first week of DDD and have a couple of entities
This is the first week I've been playing with jQuery so I have a
Possible Duplicate: Get first day of week in PHP? i have this script that
I am currently getting first day Of this week and last week values with
problem euler #5 i found the solution but i don't know why this first
Using Dozer to map two objects, I have: /** /* This first class uses
I have a JSON data like this: { hello: { first:firstvalue, second:secondvalue }, hello2:
I'm new to C++, this is my first week since the upgrade from fortran.
I've been working a week on teaching myself C# (with no C++ or Java),
first of all, this is the first week that I use swing, then sorry

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.