<HTML><HEAD>
<!--
-------------
Body Mass Index
-------------
-->
<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers
/*
THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
Copyright (c)1998 by Charles River Media. All Rights Reserved.
This applet can only be re-used or modifed by license holders of the
JavaScript Cookbook CD-ROM. Credit must be given in the source
code and this copyright notice must be maintained. If you do
not hold a license to the JavaScript Cookbook, you may NOT
duplicate or modify this code for your own use.
Use at your own risk. No warranty is given or implied of the suitability
of this applet for any specific application. Neither Erica Sadun nor
Charles River Media will be held responsible for any unwanted effects
due to the use of this applet or any derivative.
*/
//----------------------PATH UTILITIES--------------------------
// Get the grandparent directory and append aDir
function getSibling(aDir)
{
var loc = ""+document.location
// get this dir, then parent
var base = loc.substring(0, loc.lastIndexOf("/"))
base = base.substring(0, base.lastIndexOf("/")+1)
return base+aDir+'/'
}
//----------------------BMI UTILITIES--------------------------
function dobmi()
{
// determine BMI
var wt = Math.max(parseInt(document.forms[0].weight.value), 0)
var ht = Math.max(parseInt(document.forms[0].height.value), 0)
if ((wt == 0) || (ht == 0))
{
alert('Weight and Height must be non-zero values.')
return "Invalid Weight or Height"
}
var bmi = Math.floor((wt * 704) / (ht * ht))
// Get the Image Directory
var baseRef = getSibling("GRAFX")
// Frame the body
var s1 = "<BODY BGCOLOR=\"ffffff\">"
var s2 = "</BODY>"
// Create an Image
var i1 = "<IMG SRC=\""+baseRef
var i2 = ".GIF\" HEIGHT=16 WIDTH=16>"
// Initialize bmi window
parent.JCbmi.document.open()
parent.JCbmi.document.write(s1)
for (var i = 0; i < Math.min(bmi, 25); i++)
parent.JCbmi.document.write(i1+"HEART"+i2)
for (var i = 25; i < Math.min(bmi, 30); i++)
parent.JCbmi.document.write(i1+"DIAMOND"+i2)
for (var i = 30; i < bmi; i++)
parent.JCbmi.document.write(i1+"DAGGER"+i2)
parent.JCbmi.document.write(s2)
parent.JCbmi.document.close()
return "Body Mass Index is "+bmi
}
<!-- done hiding --></SCRIPT></HEAD>
<BODY bgcolor="ffffff">
<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/SPICE.JPG" WIDTH=37 HEIGHT=72
ALIGN = LEFT>Body Mass Index</H1></FONT>
<BLOCKQUOTE>
<FONT SIZE=4>
This utility calculates your Body Mass Index. Enter your height and
weight and press the calculate button. If you only see hearts, good
for you. Your height to body mass ratio is healthy. If you see
green diamonds, you might stand to lose a little weight. Black daggers
indicate that your height to body mass ratio puts you at high
risk for cardiovascular disease.
</FONT>
</BLOCKQUOTE>
<br><br>
<FORM>
Your Height (in inches): <INPUT TYPE="text" NAME="height" SIZE=5><br>
Your Weight (in pounds): <INPUT TYPE="text" NAME="weight" SIZE=5><br>
<INPUT TYPE="button" VALUE="Calculate Body Mass Index" onClick="dobmi()">
</FORM>
<FONT COLOR="007777"><H2>Discussion</H2></FONT>
<FONT SIZE=4>
This script uses the standard Body-Mass Index ratio of weight times
704 divided by height squared. Values below 25 are considered healthy;
above 30, high risk. This utility is not sanctioned by
any medical authorities. Please consult a qualified medical practitioner
for real medical advice.
<h5>Copyright ©1996 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>