فتى الريـاض
20-07-2001, 10:55 PM
<body>
<h2 align="center"><font color="#000080">Bodyfat </font><script
language="JavaScript">
<!-- hide from old browsers
function ClearForm (form) {
form.weight.value="";
form.waist.value="";
form.bodyfat.value="";
}
function VerifyForm(form) {
// Holds whether or not the form is correct
var Correct = true;
// Check for missing fields
if (form.weight.value == null || form.weight.value.length == 0 ||
form.waist.value == null || form.waist.value.length == 0) {
alert ("\nPlease fill in all of the form elements");
Correct = false;
}
// Check that only numbers are in the weight and waist fields
else {
// Holds the floats representing the weight and waist
var TestWeight;
var TestWaist;
// Parse the weight and waist values and put in the variables
TestWeight = parseFloat(form.weight.value);
TestWaist = parseFloat(form.waist.value);
// Check to see that TestWeight is a number
if (isNaN (TestWeight)) {
alert("\nMake sure to enter the weight\nas a number.");
Correct = false;
form.weight.value="";
}
// Check to see that TestWaist is a number
if (isNaN (TestWaist)) {
alert("\nMake sure to enter the waist size\nas a number.");
Correct = false;
form.waist.value="";
}
// Check that the TestWeight is greater than 0
if (TestWeight <= 0) {
alert("\nCome on. Enter a real weight.");
Correct = false;
form.weight.value="";
}
// Check that the TestWaist is greater than 0
if (TestWaist <= 0) {
alert("\nCome on. Enter a real waist size.");
Correct = false;
form.waist.value="";
}
}
// If the inputs are correct, calculate the bodyfat percent
if (Correct) {
// Holds the bodyfat number and percent
var BF;
var BFPercent;
// Make the male calculations
if (form.gender[0].checked) {
BF = -98.42 + 4.15*TestWaist - .082*TestWeight;
}
// Make the female calculations
else {
BF = -76.76 + (4.15*TestWaist) - (.082*TestWeight);
}
// Calculate the bodyfat percentage
BFPercent = BF / TestWeight;
BFPercent = BFPercent * 100;
BFPercent = Math.round(BFPercent);
// Send this number to the screen
form.bodyfat.value = BFPercent + "%";
}
}
// finish hiding from old browsers -->
</script><font color="#000080">Calculator</font></h2>
<form method="post" name="bodyfat">
<div align="center"><center><table border="2" cellpadding="5">
<TBODY> <tr>
<td><font color="#000080" face="Tahoma">ذكر ولا
أنثى؟</font><font face="Tahoma"><br>
<input type="radio" checked name="gender"
value="MalePick" align="left"> ذكر<br>
<input type="radio" name="gender" value="FemPick"
align="left"> أنثى<br>
</font></td>
<td valign="top"><font color="#000080" face="Tahoma">كم
وزنك؟(lbs.)</font><font face="Tahoma"><br>
<input type="text" size="8" name="weight"><br>
<br>
</font><font color="#000080" face="Tahoma">كم
طولك بالإنش؟</font><font face="Tahoma"><br>
<input type="text" size="8" name="waist"> </font></td>
</tr>
<tr>
<td colspan="2"> <input
type="button" value="أمسح"
onclick="ClearForm(this.form)"> <input type="button"
value="أحسب النتيجه"
onclick="VerifyForm(this.form)"></td>
</tr>
<tr>
<td colspan="2"><p align="center"><font
color="#22165A"><font تناسق وزنك مع طولك هي </FONT> <input type="text" size="10"
name="bodyfat"> </font></p>
</td>
</tr>
<font color="#22165A"></TBODY></font>
</table>
</center></div>
</form>
<font color="#22165A"><!-- END OF SCRIPT --></font>
</body>
<h2 align="center"><font color="#000080">Bodyfat </font><script
language="JavaScript">
<!-- hide from old browsers
function ClearForm (form) {
form.weight.value="";
form.waist.value="";
form.bodyfat.value="";
}
function VerifyForm(form) {
// Holds whether or not the form is correct
var Correct = true;
// Check for missing fields
if (form.weight.value == null || form.weight.value.length == 0 ||
form.waist.value == null || form.waist.value.length == 0) {
alert ("\nPlease fill in all of the form elements");
Correct = false;
}
// Check that only numbers are in the weight and waist fields
else {
// Holds the floats representing the weight and waist
var TestWeight;
var TestWaist;
// Parse the weight and waist values and put in the variables
TestWeight = parseFloat(form.weight.value);
TestWaist = parseFloat(form.waist.value);
// Check to see that TestWeight is a number
if (isNaN (TestWeight)) {
alert("\nMake sure to enter the weight\nas a number.");
Correct = false;
form.weight.value="";
}
// Check to see that TestWaist is a number
if (isNaN (TestWaist)) {
alert("\nMake sure to enter the waist size\nas a number.");
Correct = false;
form.waist.value="";
}
// Check that the TestWeight is greater than 0
if (TestWeight <= 0) {
alert("\nCome on. Enter a real weight.");
Correct = false;
form.weight.value="";
}
// Check that the TestWaist is greater than 0
if (TestWaist <= 0) {
alert("\nCome on. Enter a real waist size.");
Correct = false;
form.waist.value="";
}
}
// If the inputs are correct, calculate the bodyfat percent
if (Correct) {
// Holds the bodyfat number and percent
var BF;
var BFPercent;
// Make the male calculations
if (form.gender[0].checked) {
BF = -98.42 + 4.15*TestWaist - .082*TestWeight;
}
// Make the female calculations
else {
BF = -76.76 + (4.15*TestWaist) - (.082*TestWeight);
}
// Calculate the bodyfat percentage
BFPercent = BF / TestWeight;
BFPercent = BFPercent * 100;
BFPercent = Math.round(BFPercent);
// Send this number to the screen
form.bodyfat.value = BFPercent + "%";
}
}
// finish hiding from old browsers -->
</script><font color="#000080">Calculator</font></h2>
<form method="post" name="bodyfat">
<div align="center"><center><table border="2" cellpadding="5">
<TBODY> <tr>
<td><font color="#000080" face="Tahoma">ذكر ولا
أنثى؟</font><font face="Tahoma"><br>
<input type="radio" checked name="gender"
value="MalePick" align="left"> ذكر<br>
<input type="radio" name="gender" value="FemPick"
align="left"> أنثى<br>
</font></td>
<td valign="top"><font color="#000080" face="Tahoma">كم
وزنك؟(lbs.)</font><font face="Tahoma"><br>
<input type="text" size="8" name="weight"><br>
<br>
</font><font color="#000080" face="Tahoma">كم
طولك بالإنش؟</font><font face="Tahoma"><br>
<input type="text" size="8" name="waist"> </font></td>
</tr>
<tr>
<td colspan="2"> <input
type="button" value="أمسح"
onclick="ClearForm(this.form)"> <input type="button"
value="أحسب النتيجه"
onclick="VerifyForm(this.form)"></td>
</tr>
<tr>
<td colspan="2"><p align="center"><font
color="#22165A"><font تناسق وزنك مع طولك هي </FONT> <input type="text" size="10"
name="bodyfat"> </font></p>
</td>
</tr>
<font color="#22165A"></TBODY></font>
</table>
</center></div>
</form>
<font color="#22165A"><!-- END OF SCRIPT --></font>
</body>