根据公式(身高-108)*2=体重,可以有10斤左右的浮动。来观察测试者体重是否合

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="text" id="tex1" value="" />cm 身高
<input type="text" id="tex2" value="" /> kg 自己的体重
<input type="button" id="but" value="检测" />
</body>
</html>
<script type="text/javascript">
but.onclick=function(){
var h=Number(tex1.value);
var w=Number(tex2.value);
if(w==(h-108)*2||w+10==(h-108)*2){
alert("合格");
}
else if(w+10>(h-108)*2||w+10<(h-108)*2){
alert("不合格")
}
}

</script>

原文地址:https://www.cnblogs.com/shiguangjian/p/8298613.html