I am trying to do an activity in my web development class but I’ve ran into a problem that looks so simple but I seem to can’t get my head around it. I’ve tried other solutions but still don’t get what’s wrong or lacking in my code.
I want my program to analyze the age and identify it, to overwrite on the paragraph id of agetext, the age group (children, early working age…)
<html>
<body>
<h1>Age Group Identifier</h1>
<p></p>To find out the category of an age group, please enter the age below.</p>
<form id="agegroupidentifier">
Age: <input id="agein" type="text"><br>
<input type="button" onclick="ageInput();" value="Submit">
<p ="agetext"></p>
</form>
<script>
function ageInput() {
var ageInp=document.getElementById("agein").value;
}
if (agein =< 14) {
document.getElementById("agetext").innerHTML="Children";
}
else (agein =< 24)
document.getElementById("agetext").innerHTML="Early Working Age";
}
else (agein =< 54)
document.getElementById("agetext").innerHTML="Prime Working Age";
}
else (agein =< 64)
document.getElementById("agetext").innerHTML="Mature Working Age";
}
else (agein > 64)
document.getElementById("agetext").innerHTML="Elderly";
}
</script>
</body>
</html>