?? 18.6 電腦檢測(cè)健康情況.htm
字號(hào):
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>標(biāo)題頁</title>
</head>
<body>
<script LANGUAGE="JAVASCRIPT">
function ClearForm(form){ //清空頁面中的文本框
form.weight.value = "";
form.height.value = "";
form.bmi.value = "";
form.comment.value = "";
}
function bmi(weight, height) {//計(jì)算健康值
bmindx=weight/eval(height*height);
return bmindx;
}
function checkform(form) {
if (form.weight.value==null||form.weight.value.length==0
|| form.height.value==null||form.height.value.length==0){//判斷用戶的輸入
alert("\n請(qǐng)?zhí)顚懮砀吆腕w重!");
return false;
}
else if (parseFloat(form.height.value) <= 0||
parseFloat(form.height.value) >=500||
parseFloat(form.weight.value) <= 0||
parseFloat(form.weight.value) >=500){
alert("\n輸入的數(shù)據(jù)有問題 \n請(qǐng)重新輸入."); //輸入數(shù)據(jù)范圍
ClearForm(form);
return false;
}
return true;
}
function computeHealth(form) { //根據(jù)健康值,判斷描述信息
if (checkform(form)) {
yourbmi=Math.round(bmi(form.weight.value, form.height.value/100));
form.bmi.value=yourbmi;
if (yourbmi >30) {
form.comment.value="不要在鬧了!!!";
}
else if (yourbmi >28 && yourbmi <=30) {
form.comment.value="真的太胖了?";
}
else if (yourbmi >23 && yourbmi <=28) {
form.comment.value="不是一般的胖阿?";
}
else if (yourbmi >21 && yourbmi <=23) {
form.comment.value="您現(xiàn)在是偏胖,應(yīng)該注意飲食!";
}
else if (yourbmi >=19 && yourbmi <=21) {
form.comment.value="哇!!!您太苗條了! 是標(biāo)準(zhǔn)身材";
}
else if (yourbmi >=18 && yourbmi <19) {
form.comment.value="您是不是營養(yǎng)不良?????";
}
else if (yourbmi >=17 && yourbmi <18) {
form.comment.value="這個(gè)不是骨頭嗎????";
}
else if (yourbmi <17) {
form.comment.value="按照生物學(xué)來說這種生物是不能生存的!!!!!!";
}
}
return;
}
</script>
<form NAME="BMI" method="POST">
<table border="1">
<tr>
<td><font color="blue"><div align="center"><center><p>體重</font> (kg)</td>
<td align="center"><font color="blue"><div align="center"><center><p>身高</font>(cm)</td>
<td align="center"><font color="blue"><div align="center"><center><p>健康值</font></td>
<td align="center"><font color="blue"><div align="center"><center><p>電腦對(duì)您的評(píng)價(jià)</font></td>
</tr>
<tr align="center">
<td><input TYPE="TEXT" NAME="weight" SIZE="6" onFocus="this.form.weight.value=''"></td>
<td><input TYPE="TEXT" NAME="height" SIZE="6" onFocus="this.form.height.value=''"></td>
<td><input TYPE="TEXT" NAME="bmi" SIZE="5"></td>
<td><input TYPE="TEXT" NAME="comment" size="40"></td>
</tr>
</table>
<div align="center"><center><p>
<input TYPE="button" VALUE="確定" onClick="computeHealth(this.form)">
<input TYPE="reset" VALUE="取消" onClick="ClearForm(this.form)"> </p>
</center></div>
</form>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -