دسته بندی تناسب اندام افراد، بر اساس قد و وزن، (با javascript)

این کد، قد و وزن افراد را دریافت نموده و سپس دسته ای که فرد در آن قرار می گیرد (از نظر تناسب اندام) را نمایش می دهد :


Result

کدها :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script language="JavaScript">
function mod(div,base) {
return Math.round(div - (Math.floor(div/base)*base));
}
function calcBmi() {
var w = document.bmi.weight.value * 1;
var HeightFeetInt = document.bmi.htf.value * 1;
var HeightInchesInt = document.bmi.hti.value * 1;
HeightFeetConvert = HeightFeetInt * 12;
h = HeightFeetConvert + HeightInchesInt;
displaybmi = (Math.round((w * 703) / (h * h)));
var rvalue = true;
if ( (w <= 35) || (w >= 500)  || (h <= 48) || (h >= 120) ) {
alert ("Invalid data.  Please check and re-enter!");
rvalue = false;
}
if (rvalue) {
if (HeightInchesInt > 11) {
reminderinches = mod(HeightInchesInt,12);
document.bmi.hti.value = reminderinches;
document.bmi.htf.value = HeightFeetInt +
((HeightInchesInt - reminderinches)/12);
document.bmi.answer.value = displaybmi;
}
if (displaybmi <19)
document.bmi.comment.value = "Underweight";
if (displaybmi >=19 && displaybmi <=25)
document.bmi.comment.value = "Desirable";
if (displaybmi >=26 && displaybmi <=29)
document.bmi.comment.value = "prone to health risks";
if (displaybmi >=30 && displaybmi <=40)
document.bmi.comment.value = "Obese";
if (displaybmi >40)
document.bmi.comment.value = "Extremely obese";
document.bmi.answer.value = displaybmi; }
return rvalue;
}
</script>

</head>

<body>

<form name="bmi">
<center>
<table width=200 border=0>
<tr>
<td align=center><B>Weight:</B>
<input type="text" name="weight" SIZE="3" maxlength="3"> lbs.</td>
</tr>
<tr>
<td align=center><B>Height:</B>
<input type="text" name="htf" size="1" maxlength="1"> Ft.         
<input type="text" name="hti" size="2" maxlength="2"> In.
</td>
</tr>
<tr>
<td align=center>
<input type="button" value="Calculate BMI" onclick="calcBmi()">
 
<hr></td>
</tr>
<tr>
<td><B>Body Mass Index</B>
<input type="text" name="answer" size="3">
</td>
</tr>
<tr>
<td>
According to the Panel on Energy, Obesity, and
Body Weight Standards published by American
Journal of Clinical Nutrition, your category is:<br>
<input type="text" name="comment" size="25">
</td>
</tr>
</table>
</center>
</form>

</body>
</html>
نویسنده علیرضا گلمکانی
شماره کلید 702
گزینه ها
به اشتراک گذاری (Share) در شبکه های اجتماعی
نظرات 0 0 0

ارسال نظر جدید (بدون نیاز به عضو بودن در وب سایت)

جستجو در کلیدستان، توسط گوگل

جستجو در عنوان کلیدها

دسترسی سریع

کلید
×

شماره کلید


دسته بندی
×

شماره دسته کلید


جستجو
×

جستجو