|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
help w/ Mortgage calulations
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 |
|
#2
|
|||
|
|||
|
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. Code:
<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>
__________________
Thanks, Jaegernaut ---------------------- "We cannot solve the problems we have created with the same type of thinking that has created them." - Einstein "Rarely do we get enough information from a poster to be able to say the best possible way to code something, but no matter what, we should encourage research, education, and respect among our communities." -- Me |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
|||
|
|||
|
You're welcome.
Post again if you need more assistance.
__________________
Thanks, Jaegernaut ---------------------- "We cannot solve the problems we have created with the same type of thinking that has created them." - Einstein "Rarely do we get enough information from a poster to be able to say the best possible way to code something, but no matter what, we should encourage research, education, and respect among our communities." -- Me |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|