Seeking assistance! I attempted to create a mini loan eligibility web app using JavaScript, but encountered an issue where the displayed result did not match the expected outcome upon clicking the eligibility button.
Here is the HTML and JavaScript Code I used:
let Amount = document.querySelector("#amount").value;
let Duration = document.querySelector("#years").value;
let amt = parseInt(Amount);
let dura = parseInt(Duration);
let Message = document.querySelector("#result");
//const Income = parseInt(Amount.value);
//const Years = parseInt(Duration.value);
function eligibility(){
if(amt < parseInt(50000) ){
Message.textContent = "Please! You're not eligible for the loan";
// console.log('Try again')
} else if(amt >= parseInt(50000) ) {
Message.textContent = "Please Fill the form below and apply"
// console.log('Please Fill the form below and apply')
}
}
<html>
<form action="" role="form">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-plus"></span>
</span>
<input type="number" class="form-control" placeholder="Income" id="amount" required />
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
<input type="number" class="form-control" placeholder="Duration" id="years" required />
</div>
</div>
<button type="" class="btn btn-primary btn-block" onclick="eligibility()">Check Eligibility</button>
<div id="result">
</div>
</form>
</html>