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

  • SEARCH
  • Home
  • 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 7855551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:25:15+00:00 2026-06-02T20:25:15+00:00

Here’s the problem, I’ve been working on two pices of code recently, basic Js

  • 0

Here’s the problem, I’ve been working on two pices of code recently, basic Js which has to do with event handling, and onClick functions – everything working fine, up until today whereby upon clicking the button linking to function nothing happens. Code as follows:

<html>
<title>Calculate Your Monthly Payments</title> 

        <script language="JavaScript"> 
            function Calc(){ 
            var a, res;             
            a = parseFloat(document.monthly.borrow.value); 
            res1 = a/300;
            res2 = a/500;
            res3 = a/900;


            if (document.monthly.borrow.value == ""){
                window.alert("Enter the amount that you will be borrowing.");
                return;
            }

            else if (document.monthly.payments.selectedIndex == 0){
                window.alert("Please select a mortgage type.");
                return;
            }

            else if(document.monthly.payments.value == "1" )
            {
                window.alert("Your short term monthly repayments have been estimaded to be £" + res1);
            }
            else if(document.monthly.payments.value == "2" )
            {
                window.alert("Your medium term monthly repayments have been estimaded to be £ " + res2);
            }
            else if(document.monthly.payments.value == "3" )
            {
                window.alert("Your long term monthly repayments have been estimaded to be £ " + res3);
            } 
        }
        </script> 

</head> 


<div id="container">

        <h2>Calculate Your Monthly Payments</h2> 
        <h4>Please fill in the form below</h4>
         <form id="monthly"> 
           How much are you borrowing? (£):<font color="#900">*</font> <br /><input name = "borrow" type = "text" size = "10" id="textarea" /> <br /><br />

                Mortgage Type: <br />
                <select name = "payments">
                  <option value="" selected="selected">Please Select </option>
                  <option value="1">CompleteQuaters Mortgage 2.19% fixed until 2015 </option>
                  <option value="2">CompleteQuaters Mortgage 3.17% fixed until 2017 </option>
                  <option value="3">CompleteQuaters Mortgage 3.18% fixed until 2024 </option>
                </select>
                <br /><br />                
           <input type = "button" value = "Calculate Payments! " onclick = "Calc();" /> 
           <br />
                <p><font color="#900">*Indicates Required Fields</font></p>

        </form>
</html>

Naturally, I ran it through Chrome(20.0.1096.1) and surely enough I got an error, one error to be precise:

Uncaught TypeError: Cannot read property ‘borrow’ of undefined

I’m not sure where to go from here since this error must have been there all along and yet it was working.

Problem continues..
I’ve tested this code in all of the main browsers (Firefox, Chrome, IE) and on three different computers (Windows 7, Vista, XP) and as well Chrome Beta for Android and Mobile Safari, however, none of them will respond to the onClick event.

I also should point out that upon onClick a window normally open and displays:

“Your X term Monthly Payment is £XXXXX”.

“X” being the variable result of whatever is chosen.

I’ve been through this everything several times already but as I’m not exactly great at Js I would certainly appreciate any help I could get.


If more information is needed about the problem let me know.

  • 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-06-02T20:25:16+00:00Added an answer on June 2, 2026 at 8:25 pm

    You are using document.monthly.borrow.value so

    <form id="monthly">
    

    should be

    <form name="monthly">
    

    or you can use both as follows

    <form name="monthly" id="monthly">
    

    If you want to select an element by id then you can use document.getElementById(‘elementId’)

    DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code, which takes two version identifiers in the form 1, 5,
Here is an example: I have a file 1.js, which has some functions. I
Here is the piece of code which I use to get the count from
Here is my code...I have two dimensional matrices A,B. I want to develop the
Here a simple question : What do you think of code which use try
Here's a problem I ran into recently. I have attributes strings of the form
Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE
Here is a part of my code which sends an email: servidor = smtplib.SMTP()
Here is my problem...I have a page that loads a list of clients and
Here is some code I made :) @echo off set source=R:\Contracts\ set destination=R:\Contracts\Sites\ ROBOCOPY

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.