Click to See Complete Forum and Search --> : help w/ Mortgage calulations
kimclift
04-01-2004, 07:56 AM
Hi,
I need help with a mortgage lab. The ShowVal or even maybe the OnClick is nor working correctly. Any help would be appreciated. I am new at this. Just learning.
Thanks,
Kim
jaegernaut
04-01-2004, 09:05 AM
You aren't referencing the value of the form items, that's why it is problematic.
I also noticed that you aren't rounding to two decimal places on the payments. I've added code for that as well.
<script language="Javascript">
function Monthly(I, N, S) {
// I = yearly interest rate;
// N = number of monthly payments;
// S = loan amount;
return (S*I/12*Math.pow(I/12+1,N))/(Math.pow(I/12+1,N)-1);
}
function ShowVal() {
I=eval(document.mortgage.intrate.value); //added value
N=eval(document.mortgage.months.value); //added value
S=eval(document.mortgage.lamount.value); // added value
total=Monthly(I, N, S);
ttotal=total*N; // added for use in last line
document.mortgage.mpayment.value=total.toFixed(2); // setting 2 decimal places and added value
document.mortgage.tpayment.value=ttotal.toFixed(2); // setting 2 decimal places and added value
}
</script>
kimclift
04-01-2004, 10:17 AM
Thanks for your help. It is now working - but I have some more code that needs to be added that I may need help with.
AGAIN - THANKS
I have been struggling with this for weeks!
jaegernaut
04-01-2004, 10:19 AM
You're welcome.
Post again if you need more assistance.