Thanks for the tips Matt, however I'm restricted to using only XHTML so I don't really have a choice. I wrote up another script but when i click on calculate it does nothing and just shows theres an error on the page. Could anyone help please?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>BMI Calculator</title>
<script type="text/javascript">
<!-- Hide script from non-script-friendly browsers
function BMI_Calculator()
{
n = prompt('What is your age?',"");
if (n <= 17)
{ document.write("We are unable to calculate your BMI"); }
else if(n => 18)
{ h = prompt('What is your height in metres?',"");
w = prompt('What is your weight in kilograms?',"");
bmi = Math.round(w / (h*h));
switch(bmi)
{
case bmi <= 19:
message = "Underweight";
break;
case bmi >= 20 && bmi <= 25:
message = "Acceptable";
break;
case bmi >= 26 && bmi <=30:
message = "Overweight";
break;
case bmi >= 31:
message = "Obese";
break;
default: message = "Error!";
break;
}
comment = "<html><head><title>Your BMI</title></head><body>" +
"<h1>BODY MASS INDEX (BMI) CALCULATOR</h1><p>Your height = " +
h + "<br>Your weight = " + w + "<br>Your BMI = " + bmi + "</p><p>" +
"<h2>what your BMI Indicates</h2><br>" + message + "</p>";
document.write (comment);
}
// stop hiding the script-->
</script>
</head>
<body>
<a href="javascript: BMI_Calculator()">Calculate</a>
</body>
</html>