我想创建一个评分计算器,我想知道一些事情。我有这个问题,每当我输入一个数字时,它就会显示为“未定义”。请帮忙。
<script>
function Calc() {
var grade = document.getElementById("grade");
var totalGrade = document.getElementById("totalGrade");
var gradePercentage = eval(grade/totalGrade)*100;
document.getElementById("result").innerHTML = gradePercentage.value + "%";
}
</script>
<input type = "text" id = "grade" style = "width:50" autocomplete = "off"> / <input type = "text" id = "totalGrade" style = "width:50" autocomplete = "off">
<br> <br>
<input type = "button" value = "Calculate" onClick = "Calc()">
<p id = "result" name = "r1"> </p>
</html>
qq_花开花谢_0
长风秋雁
相关分类