In Lab04 (Question1, Lab04), you built the first page of your website, "About Me", a personal biography page. You will build on this page to design a complete personal website. Your site requirements are as follows:
Use a form with two <input type="text" name="..."
size=30>
fields, a textarea
with 5 rows
and 25 cols to display the answer, and a "Go" button. Your page
should look like this after the user has typed 81 and 1.8 into the
input boxes and clicked the "Go" button:
lab5q2.html
,
and paste the following into your text file. <!DOCTYPE html>
<html>
<head>
<title>
INSERT TITLE HERE REPLACING THIS LINE
</title>
</head>
<body>
INSERT BODY HERE
</body>
</html>
body
should start with an <h2>
heading ("BMI Calculator"). Then you need your form tag. Since
you are not sending anything to a server, all you need is:
<form name="form1"> ... </form>In between, where the ... is, you put your text boxes, textarea, and Go button.
<input
type="text"...>
"mass" and your second one "height",
and your <textarea ...>
"area1". So,
Type your weight in kg <input type="text" name="mass" value=""><br>and similarly for the height box. The <br> tag starts a new line - you may need to insert 2 or 3 more of these to get the interface to look right. You can access what is typed into the mass box by referring to
mass.value
and what
is typed into the height box by refer
ring to height.value
<input type=button
name="btn1" value="Go" onclick=...>
. The ... is
discussed in the next step. onclick
action for the "Go" button should be of the
form "area1.value
=some
mathematical expression". The algebraic expression will
involve mass.value and height.value and will calculate the BMI -
see the formula in the first sentence of the Question 3
instructions. So it will be:"area1.value=mass.value/(height.value*height.value)"
textarea
box. For example, if
someone weighs 100 kg and is 2 metres high, then their BMI
should be 100/(2*2) = 25. Save the Notepad work, open lab6q1.html
in your web browser. Test the interface, check, and fix if
necessary. When this is OK, put the string 'BMI is ' in front of
the BMI value using the string concatenation operator, +. This
is explained in the next step. NaN
, this
stands for "Not a Number". It signifies that you have tried to
perform arithmetic with something that is not a number (e.g. an
empty string or a string of alphabetic characters). You may get
Infinity
of -Infinity
if you typed in
0 for the height for example which would have caused your
calculation to attempt to divide by 0.