+ 2
Why this code is not working here...? Can anyone help..!
5 Answers
+ 8
It's because your code in JS section loads before your html; delay it with onload or similar event it should work fine.
this.onload = function(){
//your JS code here...
}
+ 2
//Fix your errors. Try this in js
//on clicking button action
window.onload = function() {
function calculateAmount() {
// storing the data
var income = document.getElementById("income").value;
var interest = document.getElementById("interest").value;
var years = document.getElementById("years").value;
//validation
if(income === "" || interest === "")
{
window.alert("Please Enter a Valid Input!");
return;
}
if(years === "" || years <= 1)
{
years = 1;
}
var fAmount = (income * 12 * interest * years) / 100;
//display
document.getElementById("totalinterest").style.display = "block";
document.getElementById("amount").innerHTML = fAmount;
//hide amound and returns
// document.getElementById("totalinterest").style.display = "none";
}
document.getElementById("calculate").onclick = calculateAmount;
};
0
thankyou all for answering 🙂
0
now it's working ☺️