My assignment ask to create a web page that will calculate the BMI of a person by using the formula weight*703/(height*height).
I created my code but I am so confused about how to place the formula, and what values to use for the text boxes.
should i use the same function twice, where does the height part belong in?
this is what it asks.
create a script with a function named calcBMI(): I did
it performs the calculation using the values in the weight: i get that
Reference the text boxes from within the function by using the document object, form name, and name and value attributes of the text boxes(do not use function arguments)- this part has me lost. help please!
here's my code;
<!DOCTYPE HTML>
<html>
<head>
<title>Don's Weddings Guestbook</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function calcBMI(){
calculation -= yourweight;
yourweight = document.discription.weight.value *703;
calculation += yourweight;
document.calculation.BMI.value = ""
}
/* <![CDATA[ */
/* ]]> */
</script>
</head>
<body>
<form action="" name="discription">
<P>Weight
<input type="text" name="weight" style="width: 180px" onchange="calcBMI()"/></p>
<p>Height
<input type="text" name="height" style="width: 152px" onchange="calcBMI()"/></p>
</form>
<form action="" name="calculation">
<p>BMI
<input type="text" name="BMI" style="width: 152px" onchange="calcBMI()"/></p>
<p><input type="button" value="calculate" onclick="addGuest()"/></p>
</form>
</body>
</html>

New Topic/Question
Reply


MultiQuote






|