【发布时间】:2017-05-31 22:59:50
【问题描述】:
到目前为止,这就是我所拥有的,但我无法让它显示结果。我希望能够输入诸如“75”之类的数字,单击按钮,然后在底部的文本框中输入“C”等其他数字。 到目前为止,我的代码如下所示:
当我点击“点击这里”时,我不想让答案单独出现,我希望它显示在只读文本框中。
<!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>
【问题讨论】:
-
你想在页面的什么地方或 input#letter 元素中显示结果?
-
你有一个额外的右大括号。
-
@karthick 我希望字母等级显示在只读的输入文本框中。
标签: javascript php html if-statement