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.
@jaegernautApr 01.2004 — #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.
<i> </i><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 }