I'm new to js and I need my result "monthly_payment" to display on the form in a text box. Can anyone tell me how to do it? A colleague suggested to put it in a div tag and use .InnerHtml, however, I don't know how to do that and I am unfamiliar with the .innerHtml property(?)
function find_payment(PR, IN, PE) {
var PAY = (PR * IN) / (1 - Math.pow(1 + IN, -PE))
return PAY
}
//var principal = 200000
//var interest = 0.088
//var term = 30
//var monthly_payment = find_payment(principal, interest / 12, term * 12);
var principal = document.formpage.principal.value;
var interest = document.formpage.interest.value/100;
var term = document.getElementById('years').term.value;
var monthly_payment = find_payment(principal, interest / 12, term * 12);
//document.write("Amount of the loan: $" + principal + "<br>" +
//"Annual interest rate:\t" + interest * 100 + "%<br>" +
//"Term of the mortgage loan:\t" + term + " years<br><br>" +
//"Monthly payment: $" + monthly_payment)
//alert("Amount of the loan:\t$" + principal + "\n" +
//"Annual interest rate:\t" + interest * 100 + "%\n" +
//"Term of the mortgage loan:\t" + term + " years\n\n" +
//"Monthly payment:\t$" + monthly_payment)
Bookmarks