<SCRIPT language="JavaScript">
function bmiCalc(form) {
var weight = Number(form.wt.value);
var height = Number(form.ht.value);
if (!checkNum(weight,"WEIGHT")) {
form.wt.select();
form.wt.focus();
return false
}
if (!checkNum(height,"HEIGHT")) {
form.ht.select();
form.ht.focus();
return false
}
if (form.wu.selectedIndex == 0) {
// What units for weight?
// 0 = lbs
// 1 = kg
weight = weight * 0.45359237; // Convert wt (lbs to kg)
}
if (form.sex[1].checked) { // Is the patient female?
// 0 = male
// 1 = female
leanConvert = 148;
idealConvert = 45.5; // conversion factors for women
} else {
leanConvert = 128;
idealConvert = 50; // conversion factors for men
}
if (form.hu.selectedIndex == 0) {
// if height units are "inches"
heightInches = height;
heightMeters = height * 2.54 / 100;
}
if (form.hu.selectedIndex == 1) {
// if height units are "cm"
heightInches = height / 2.54;
heightMeters = height / 100;
}
if (form.hu.selectedIndex == 2) {
// if height units are "meters"
heightInches = height * 100 / 2.54;
heightMeters = height;
}
var bsa = 0.20247 * Math.pow(heightMeters,0.725) *
Math.pow(weight,0.425);
var leanKg = 1.1 * weight - leanConvert * (Math.pow(weight,2) /
Math.pow((100 * heightMeters),2));
var leanLbs = leanKg * 2.2046226;
var idealKg = idealConvert + 2.3 * (heightInches - 60);
var idealLbs = idealKg * 2.2046226;
var bmi = weight / Math.pow(heightMeters,2);
bsa = rounding(bsa,2);
leanKg = Math.round(leanKg);
leanLbs = Math.round(leanLbs);
idealKg = Math.round(idealKg);
idealLbs = Math.round(idealLbs);
bmi = rounding(bmi,1);
if (bmi < 18.5) {
var interp = " اقل من المعدل الطبيعي"
} else {
if (bmi < 25.0) {
var interp = "مبروك بحدود المعدل الطبيعي"
} else {
if (bmi < 30.0) {
var interp = "اعلى من المعدل الطبيعي"
} else {
var interp = "وزنك زائد يجب عليك الحرص في انقاصه"
}
}
}
form.bsa.value = bsa;
form.leanKg.value = leanKg;
form.leanLbs.value = leanLbs;
form.idealKg.value = idealKg;
form.idealLbs.value = idealLbs;
form.bmi.value = bmi;
form.interp.value = interp;
return true
}
function checkNum(val,text) {
if ((val == null) || (isNaN(val)) || (val == "") || (val < 0)) {
alert("رجاء ادخال ارقام في حقلي الطول و الوزن");
return false
}
return true;
}
function rounding(number,decimal) {
multiplier = Math.pow(10,decimal);
number = Math.round(number * multiplier) / multiplier;
return number
}
// BY
[ندعوك للتسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الرابط]</SCRIPT>
<FORM method="post" name="bmi">
<table align="center" cellspacing="1" cellpadding="0" border="0" bgcolor="#000099">
<tr><td>
<table cellspacing="3" cellpadding="3" border="0" bgcolor="#F5F5F5" width="300" style="FONT-FAMILY: Tahoma; FONT-SIZE: 12px" dir="rtl">
<tr><td> <font color="#000080">الجنس :</font>
<INPUT checked name="sex" type="radio" value="0">ذكر
<INPUT name="sex" type="radio" value="1">انثى
</td></tr>
<tr><td> <font color="#000080">الوزن :</font>
<INPUT maxLength="4" type="text" name="wt" size="3">
<SELECT name="wu" size="1">
<OPTION value="0">رطل
<OPTION value="1" selected>كجم
</SELECT> </td></tr>
<tr><td>
<font color="#000080">الطول :</font>
<INPUT maxLength="3" name="ht" size="3">
<SELECT name="hu" size="1">
<OPTION value="0">انش
<OPTION value="1" selected>سم
<OPTION value="2">متر
</SELECT> </td></tr>
<tr><td>
<INPUT name="button" onclick="bmiCalc(this.form)" type="button" value="احســـب"> </td></tr>
<tr><td align="center"> <font color="#ff0000">النتائج :</font> </td></tr>
<tr><td><font color="#663300">مساحة سطح الجسم :</font>
<INPUT maxLength="5" name="bsa" size="5">
م<SUP>2</SUP>
</td></tr>
<tr><td><font color="#663300">الوزن بدون شحوم :</font>
<INPUT maxLength="5" name="leanLbs" size="3">
رطل <b>=</b>
<INPUT maxLength="5" name="leanKg" size="3">
كجم</td></tr>
<tr><td><font color="#663300">الوزن المثالي لك هو :</font>
<INPUT maxLength="5" name="idealLbs" size="3">
رطل <b>=</b>
<INPUT maxLength="5" name="idealKg" size="3">
كجم</td></tr><tr><td>
<font color="#663300">نسبة وزنك لمسطح الجسم :</font>
<INPUT maxLength="5" name="bmi" size="5">
كجم/م<SUP>2</SUP>
</td></tr>
<tr><td align="center">
<INPUT maxLength="12" name="interp" size="40" style="text-align: Center; color: #008000; border-style: solid; border-width: 1; margin-left: 0"></td></tr></table>
</td></tr></table> </FORM>