Hi everyone. I am trying to set up a loan approval form. I am looking to have the js file separate from the html. Here is what I have. I think I am not connecting something but am frustrated. Any help would be appreciated.
.htm
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“
<html xmlns=”
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<script type=”text/javascript” src=”new_file.js”></script>
<title>New Web Project</title>
<style type=”text/css”>body {background-color: #CCCCCC}</style>
</head>
<body>
<h1>Loan Application</h1>
<form id=”Loan Application” action=”form_action.asp”>
<fieldset>
<legend>Please enter the following information:</legend>
<label for=”Annual Income”>Annual Income</label>
<br />
<input type=”text” name=”annual income” id=”annual income” value=”40000″ />
<br />
<label for=”credit”>Credit Score</label>
<br />
<input type=”text” name=”credit” id=”credit” value=”500″ />
<br />
<label for=”education”>Education Level</label>
<br />
<select name=”education” id=”education”>
<option value=”High School”>High School</option>
<option value=”Associate’s Degree”>Associate’s Degree</option>
<option value=”Bachelor’s Degree”>Bachelor’s Degree</option>
<option value=”Postgraduate Degree”>Postgraduate Degree</option>
</select>
<br />
<br />
<input type=”button” value=”Calculate” onclick=”result()” />
<br />
</fieldset>
<DIV id=”output”> </DIV>
</form>
</body>
</html>
.js
function loanApp(income, credit, education){
if(income >= 0 || income <= 40000){
return 1;
} else {
if(income >=40001 || income <= 80000){
return 3;
} else {
return 5;
}}
if(credit >= 300 || credit <= 500){
return 1;
}else if(credit >= 501 || credit <=650){
return 3;
}else {
return 5;
}}
switch (education) {
case “High School”:
result = 1;
break;
case “Associate’s Degree”:
result = 2;
break;
case “Bachelor’s Degree”:
result = 3;
break;
case “Postgraduate Degree”:
result = 5;
default:
result = “That was not a valid selection.”;
}
function result(answer){
var answer = income + credit + education;
if (totalScore >= 3 || totalScore <= 7) {
document.getElementById(output).(“I’m sorry but your loan has been declined.”);
}
else
if (totalScore >= 8 || totalScore <= 10) {
document.getElementById(output).(“The loan is approved at 8.5% interest rate.”);
}
else {
document.getElementById(output).(“Your approved at a 7% interest rate.”);
return answer;
}
}
I want to call my function with the document.getElementById.