Bank Website - Calculating Loan Repayment With Interest
Jun 10, 2010
I am having a few problems with my JS, and now that the module has finished, I find myself struggling still. I am going to post my JS and the HTML page its related to. The site is a mock up for an assignment - basically, its a pretend bank website where a person applies for a loan, and all my JS does is work out if the applicant does the following correctly:
Enters repayment years 1 to 25
Enters a loan amount of 1000 to 250000
Checks a box for loan protection
Calculate button
Reset Button
Then tells the user what it is going to cost them from interest to total amount to be paid.
Javascript:
function init(){
var baserate=4.25;
var amount=parseInt(document.getElementById("loan").value);// end bracket missing - done
var repaymentyears=parseInt(document.getElementById("repaymentyrs").value);// end bracket missing - done
var rate;
var interest;
var loanprotect=5;
var total;
var monthlyrepayment=repaymentyears*12; .....
i want the code below to display the total loan repayment amount instead of the monthly payment payment = principle * monthly interest/(1 - (1/(1+MonthlyInterest)*Months)) , eg if if l0an is 20$ payment is in 4 months, intrest rate is 15% display = amount to be repaid.
does anyone know of a timepicker that i can disable weekends and bank holidays (or that at least easily has a place i can add code to disable days by making a call to my database of holidays in ajax?)
I'm a JavaScript newbie and need help with code.Given principle, yearly interest rate and time in years, I need to calculate interest earned and the ending amount in the account at the end of time.
Formulas:
I=P*R*T S=P+T
This is what I have which didn't work:
<script type="text/javascript"> var P,R,T,I,S; P=prompt("enter your Principle","");
The exercise problem is to "MODIFY the code in the "calculate_click" event so interest is added to future value just once each year for the number of years that they were entered by the user". The calculation as you see it below assumes an amount is invested MONTHLY (not just once), and the interest is calculated accordingly. This is what I think the problem is trying to calculate: using a $100 one time investment at 10% interest (compounded once annually) for one year = $110 as the future value. For two years, the future value should equal $121 (110 + (110*.10)). Okay, if my math is wrong, let me know. This is what I'm trying to get it to match to.
I have been able to modify the calculate_click function to compound the interest annually (it does it monthly now). Cool. I cannot get it to stop adding $100 annually. See my math above? I think that's the answer. My manipulation of the code yields $110 for the first year, $231 for the second year, etc. The $231 is incorrect cuz it adds an extra $100. See, this is a simple interest calculator I can't figure out! The original code is below that calculates the investment as a monthly investment as opposed to one-time. To avoid confusion, I did not include any of my modifications. But yeah. I know that the major culprit is how the "for" loop is being executed. I've highlighted where I think the code needs to be changed, but I haven't changed it here. Note the first function is a shortcut to execute getElementbyID.
The Code: var $ = function (id) { return document.getElementById(id); } var calculate_click = function () { var investment = parseFloat( $("investment").value ); var annualRate = parseFloat( $("rate").value ); var years = parseInt( $("years").value ); $("futureValue").value = ""; .....
I have a mortgage calc that is adding an extra decimal place to my interest rate. To see this in action go to: [URL] Change the interest rate to 7.5 Click Calculate Payment Click Create Amortization Chart On the following screen you'll see a recap of your data and the interest rate will now say 7.55. Same thing happens if you enter 6.2. Next screen shows 6.22/. I've attached the html and js files in a zip.
I'm trying to code a feature for my website using DHTML where the person viewing the website can rotate between viewing the positive/negative points of the website being reviewed. This example was in the publication called Using HTML 4 by Lee Anne Phillips. Code:
I have a ajax program on a page on website A. And I need to let it talk to a program on website B. I tried to put website B into the url of the parameter but it doesn't work.It gives me a "[objet XMLHttpRequest]" error.here is the code on website A:
i have a table, with 2 numeric values at the minute, if the checkbox is selected I want the total price to be shown? this is the form I have with the numeric values
I am trying to write a script that will take a date of birth and another date and, if the person was over 75 years old on the createdDate, return "true" (otherwise return "false").
Unfortunately my code doesn't seem to return either 'true' or 'false'!
The code is:
var dateofBirth="30/10/1982"; var createdDate="01/12/2010"; var sd = dateofBirth.split('/'); var dob = new Date(sd[2],sd[1],sd[0]);
I want to create a link that a user can click which will create a popup telling the user their ip address. I have:
var ip = new java.net.InetAddress.getLocalHost().toString(); alert("Your IP address is: " + ip.substring(ip.indexOf("/")+1))
but this does not seem to work. It says the ip is 127.0.0.1. Strangely, this piece of code used to work but all of a sudden it doesn't for some unknown reason. Can anyone tell me what's wrong with the above code?
I have two date fields (check in, check out) and "number of days" field.
I want the script to calculate automatically the difference. For example: I have defaults dates, and I want the script to put the difference in "number of days" field. And if the user will change the date, the number of days will change automatically.
I am having difficulty getting the following assignment to run properly:Many companies charge a shipping and handling charge for purchases. Create a Web page that allows a user to enter a purchase price into a text box and includes a JavaScript function that calculates shipping and handling. Add functionality to the script that adds a minimum shipping and handling charge of $1.50 for any purchase that is less than or equal to $25.00.For any orders over $25.00, add 10% to the total purchase price for shipping and handling,but do not include the $1.50 minmum shipping and handling charge. The formula for calculating a percentage is price * percent / 100. For example, the formula for calculating 10% of a $50.00 purchase price is 50 * 10 / 100, which results in a shipping and handling charge of $5.00. After you determine the total cost of the order (purchase plus shipping and handling), display it in an alert dialog box. Save the document as CalcShipping.html.This is what I have after working on it round and round for 4 hours yesterday:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">[code].....
I've been googleing for a auto calculating form and found nothing, I just want something .. some form, that can add values from different fields ... and make a sum .. in real time ... meaning that ... if I put X value in field #1 and Y value in field #2, at the bottom or somewhere I should have the X+Y value :P..
Im trying to calculate the mean/average of numbers in an array.how can i get the length of an array to perform in a simple / maths problem whilst being flexiable to the length of the array?
I am writing a form and doing a bunch of calculations one of which is a percentage based on the value selected. I am returning a correct result for two of the values but for the other two I am not.The 'discount' value is what I am looking for. It should return as 0 for values of 1 but it is doing the math as though it is multiplying by 1. And again for the value of 6 it should be 10% but is taking the value as 4.6 or something.Code is below I've included all of it (sorry) for better ease of understanding the math that is happening:
I am not a developer so not so familiar with javascript. Suppose I have a map with ten junctions and based on that map. I need to calculate all the possible routes between one junction to another. How do I represent the map in javascript and how do I code the function to calculate all the possible routes?
I was wondering if it is possible to figure out the amount of time passed from a specific time in history till the present? If so how? I have tried so many different things and I am not getting the right returns.
I am writing a DHTML application which uses AJAX to show dialogue windows etc.. (all the bells and whistles).When I display a DHTML dialogue in the foreground, I use JS to create a div which is a "layer" in between the foreground and the background which essentially "darkens" the background and disables all background functionality. Forcing the user to take action in the dialogue.How do I get the total scrollable area of the page so I know how big to make the "dark" div?I have tried all of these:
They all work in one browser or another, (I am testing in IE, FF and Opera) but none of them give me the correct values for the exact scrollable area of the page.