# Algorithm To Calculate Mortgage Payments..

Nov 2, 2004

Does anybody know of an algorithm to calculate mortgage payments? e.g.

Amount: 100,000
Interest Rate: 4.5%
Term: 25 Years

Monthly Payments: x

I've looked at other js scripts to do this but it seems alot more involved then I thought, and because they use non descriptive variable names I can't work any of them out..

## Calculate Mortgage Payment

Feb 16, 2005

I'm trying to create a mortgage payment calculator in Javascript and am having problems. My algorithm seems correct but it's not giving the right results. Im using this code:

function do_calc_payment(){var term = document.calc_payment.term.value;var rate = document.calc_payment.rate.value;var amount = document.calc_payment.amount.value;var j = rate / (12*100);var m = term * 12;var payment = amount * ( j / (1 - (1 + j) ^ -m))var result = "\$"+Math.round((payment)*1000)/1000;if(isNaN(payment)){document.calc_payment.rate.value="";document.calc_payment.amount.value="";result="Not a Number";}if(payment.length>=15){result="Max Characters";}document.getElementById('new_payment').innerHTML = result;}

## Algorithm

May 6, 2005

i am trying to store some shopping cart details in a cookie. I have been able to do that but i want to now retrieve the values and put them in a shopping cart table. An example of the cookie file is

Product1=value,Quantity1=value,Price1=value,Extras1=value;
Product2=value,Quantity2=value,Price2=value,Extras2=value;

I have been able to retrieve the 2 cookies

{
}

But now for each Product i want to retrieve the 4 values. Can anyoine help me with this or suggest a better way to achieve the same thing.

## Mortgage Calculator Script

Nov 4, 2003

Where could I find a mortgage calculator script I could place on my website? I found a really cool one at www.dave.imarc.net/php free to use but I have a hard time understanding how to install it. I really don't even know what php is.

Could someone maybe guide me out of this programming lingo darkness?

## Creating A Monthly Mortgage Calculator

Oct 12, 2010

I am trying to create a monthly mortgage calculator, I have been able to make it show prompts for Amount of loan; Interest rate; and Term of loan (in months), but it will not display the results. Below is the code I have utilized to get this far.

[Code]....

## Functions Called Correctly In A Mortgage Calculator

Oct 13, 2009

I've been trying to write a Javascript Mortgage Calculator for the past day and I believe I've got the structure right, although for some reason my functions must not be operating correctly or are not being called correctly. I'm almost afraid to say that it could be an error in the functions usage within the while loop. This Mortgage Calculator uses the principle of "bisection" to guess at the monthly payment necessary to fulfill the standards of the mortgage in question. This means that the loop is used to consistently halve the value of a guess until the correct monthly payment is guessed. Here is the code:

<script type=text/javascript>
function calcMortgage (amountText, yearsText, interestText) {
// constant definitions
// variable declaration
var amount = Number(amountText);
var years = Number(yearsText);
[Code]...

## Recommended Algorithm To Obfuscate Code?

Oct 20, 2009

I want obsfucate and compress the code for my website (HTML, CSS but especially Javascript). Are there any industry standard algorithms that are recommended?

## Optimizing String Shortening Algorithm?

Aug 16, 2010

I've written a function that "condenses" a string if it is too long.

function shortenMsg(msg,maxLen){
if (msg.length > maxLen){
var over = msg.length - maxLen, // amount that needs to be trimmed

[Code]....

Each of the methods 1-3 is the amount that that specific method can trim from the string. I'd like to be able to trim as little as possible.

For example, if the string needs 5 characters to be trimmed, and method1 can trim 8 characters, but method3 can trim 6, then method3 should be used. If none of the methods can individually trim the string enough, then I'd like the optimal combination of the methods that will get the job done.

I can't figure out what sort of code structure I need for this (besides a ton of if/else statements). Maybe an array that contains each of the methods, arranged in increasing order....?

## What Is The Algorithm To Compute The Factorisation Of An Integer?

Oct 30, 2006

I need some ideas on how to compute the factorisation of a non-zero integer?

For example:

if the user input is 8, its factorisation is 1 * 2 * 2 * 2;
if the user input is -300, its factorisation is -1 * 2 * 2 * 3 * 5 * 5

Does anyone know?

## Algorithm Only Finds Vertical Path?

Jan 19, 2010

I recently started on an browser based MMORPG, I just found 1 major issue.I'm using these libraries

JS A* Algoritm ( http://devpro.it/code/137.html )
Jquery ( http://www.jquery.com/ )
Jquery UI (http://ui.jquery.com/ )

So I'm using a little piece of JavaScript code in which im accessing the AStar function. The downside is, the AStar algorithm only finds vertical tiles. (See screenshots below)

function mapmouse (obj) {
//Get the coordinates
coords = obj.id.split('_');

[code]....

If you choose a non-vertical path, var path gives an empty array (path.length = 0 )If I choose a vertical path, it's working as intended.

As you can see with this little test here, the AStar function itself is working properly (the libs.js is used by both the game and the example)[URL]

## Mortgage Calc Adding Extra Decimal Place To Interest Rate

Oct 12, 2009

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.

## Rock-Paper-Scissors Algorithm - Code A Java Class That Plays ?

Dec 5, 2011

I have an assignment to code a java class that plays rock, paper, or scissors. The class can access the history of past gestures played by both itself and its opponent, but nothing else. The class will be played against others in 10,000 matches and the winner will be determined via round robin format. Other than using a greedy algorithm to determine statistically the best choice from prior gestures and basic pattern recognition I have no decent ideas.

## How Do You Calculate A Sum?

Sep 22, 2004

I want to add onto my ebay auction a calculation which would show the unit price of a box of 5 electrical sockets.

So say it is currently on auction at £5.62 and I charge £1.99 Postage & packing thats a total of £7.61 with a unit price of £1.52. Then £1.52 is the figure I want to output and show on screen.

## How To Calculate With JS?

Nov 20, 2002

I'm just starting out in JS and would like to know how to solve this.
I have an HTML form with 3 checkboxes, like a would-be order form. For example, on checkbox 1, the product is a toy car that costs \$5.00, second box is a cigar cutter for \$50, etc. I to have a button that when clicked, enters the total price (no taxes or subtotals) into a textbox field below in the same page.

## Calculate While I Type

Jun 29, 2006

I believe that this has been answered somewhere but I cannot find it. I have 51 textboxes on page. In 50 I can enter value. 51st should tell me what is average of entered numbers.

As user types I want script to iterate trough form count and sum non-empty fields and than divides this two numbers.I need to sum values from fields that have value (not emty fields) and to divide this number by number of non empty fields. This should occur on every change in any of those 50 textboxes so to have live preview of average.

I'm really new to JS and I don't know even how to sum these numbers.

## JQuery :: Way To Calculate A %

Mar 6, 2010

I have some data thats in a number, lets say 5455
.
Id like to get the TAX from an input, say like 2.5 percent. code...

## JQuery :: Calculate X And Y Of A Div?

Jul 9, 2010

I want to calculate X and Y of a div, but I get an infinite loop, can you tell me please what's the problem with my code? code...

## Calculate The Time Different?

May 9, 2010

I built 2 steps script - in the first page the visitor choose the date he want to schedual his appoitment and his location:

PHP Code:

<select name='zone'>
<option value='-4' selected> USA - EST</option>
<option value='-7'>USA - PST</option>

[code]....

In the second page he need to choose the time he want for his appointment (the time is in GMT+3 -> my local time). in this page the script also get the time zone and the date that he choose in the previous page (using POST - PHP). the date saved in variable. I used unix time (MKTIME function) I want that every time my visitor choose time (from drop-down box) a new cell/DIV will appear with his local time.for example - when he choose date: 10 May 2010, time zone: Austrlia - East Coast (+8 Hours) and time 22:00, New DIV will appear with the date "11 May 2010, 03:00AM" (there are 5 hours different).what is the JS what caculate and show the visitor local time?(I have, in PHP, only his time zone and the date that he coose in the first page)

## Calculate Value From Drop Box?

Apr 11, 2010

I have tried many time to make the calculation to appear at the total text box.

here is my coding..

<html>
<title>
PRESENTATION EVALUATION FORM

[Code]....

## Calculate Once New Value Is Typed In?

Apr 8, 2011

I'm working on creating a custom calculator to determine the amount of money / credits users may earn from referrals. I've tested onChange, and it will work only when I have changed to a new field or clicked off that field. How do I make this calculate live?

So if the current value is 5 and I change it to 6, it will automatically recalculate the new value.

You can see what I'm working on here:

[URL]

Note: The one I'm testing is the 1st Level field. For now i'm just having it display the date.

## How To Calculate Properly?

Feb 15, 2007

Can someone explain to me how I should code to calculate this?

I want to let the user add 4 different numbers (this is done) and then I want to + these numbers with each other.

This is the code I got: var medel = tal1+tal2+tal3+tal4 ;

Let say the user enters 1+2+3+4. Then the result should be 10. But I get this number as result: 1234

What have I done wrong?

## Calculate Each Row And Then Total

Jul 26, 2011

I am making what I call a PM (Preventive Maintenance) Kit list. My users will use this list to generate a printable sheet to tell me what they used out of there kit. The list includes pricing per part and I would like the list to calculate the costing as they enter each item. So a total per line and an overall total cost.

I have included a snap shot of the page and below is the code. I can do this sort of thing on a small scale with just adding two lines but I am not sure how to modify it to handle this scale. You can see the script towards the bottom of the page. That is my lame attempt to make the per line costing happen but NOTHING happens.

<?php
require "../config/bpts_config.php";
// Start the session
//session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
[Code]...

## How To Calculate CGPA Using PHP

Mar 31, 2009

This is my coding that I try but I still cannot get the function to calculate cgpa.
<script language="Javascript" type="text/javascript">
/*Gred*/
function DisplayGred (GredPair) {
var Gred = GredPair.split('|');
var jam_kredit = document.getElementById('jam_kredit').value; (user input pay amount student pay for course)
document.getElementById('pointer').value = Gred[1]; (display course fee when item is selected)
}
function CalculateCGPA () .....

This is the interface look alike, the code subject, subject name and credit hours are retrive from the database, so how to calculate it?
</p>
<form id="form1" name="form1" method="post" action="">
<table width="552" height="82" border="0" class="tborder">
<tr bgcolor="#006699" class="text2">
<td width="17" bgcolor="#000099"><div align="center" class="style3"><strong><font size="2">Bil</font></strong></div></td> .....

## Calculate 2 Values

May 13, 2005

I want to have 1 option box with values 10 100 1000 10000 etc in it , then i want to be able to select eg 100 and underneath it will show 100x25 which would be 2,500 so i want 1 box that has values of ten , hundred , thousand etc and they multiply by 25 and show underneath .

## Can't Calculate A Negative Value

Jul 19, 2011

I have 3 textbox controls on my web page that are numeric currency fields in which a user can enter a numeric value, either positive or negative into TB1 and TB2 (both of these fields go thru edit checks to make sure a numeric value is entered and then return a currency value ie; \$2500.00). TB3 is calculated resulting in TB3 = TB1 ((\$6500)) - TB2 (\$2500).

My problem is that if a user enters a negative value for TB1, it returns a "NaN" and the value in TB3 turns out to be the same value as in TB2. Essentialy the calulation ends up being 0 - 2500 = 2500 (see screenshot). I've attached 2 functions below.

Code:
function cal_Overage_Shortage() {
if (make2Number("TB_LowPoint") <= 0) {
document.getElementById("TB_OverageShortage").value = GetValueTextbox("TB_LowPoint") + GetValueTextbox("TB_RequestedLowPoint");

[Code]....

## Calculate All Formulas For Ppm?

Apr 28, 2009

Using this formula for parts per million, can somebody please show a SIMPLE example of how to calculate all formulas for ppm?i tried everything..like in kilograms, etc...anyway, the link:[URL]