So far this is what I have but I can't get it to display the result. I want to be able to enter a number such as "75", click the button, and then the bottom textbox to say "C" and so on with other numbers. So far my code looks like this:
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
var score = document.getElementById("score").value;
if (90 <= score)
{document.write ("A");}
else if (80 <= score && score < 90)
{document.write ("B");}
else if (70 <= score && score < 80)
{document.write ("C");}
else if (60 <= score && score < 70)
{document.write ("D");}
else
{document.write ("E");}
}
}
</script>
</head>
<body>
Grade % <input type="number" id="score" value=""><br>
<p><button onclick="myFunction()">CLICK HERE</button></p>
Letter Grade <input type="text" id="letter" readonly><br><br>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire