RSS Forums RSS
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Javascript help!

Join Date: Mar 2006
Posts: 117
Reputation: manal is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 15
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: Javascript help!

  #2  
Mar 20th, 2007
Originally Posted by
[code
<?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(bmi)
{
var bmi = w / (h*h);
return bmi;
}
//stop hiding the script-->
</script>
</head>

<body>
<script type="text/javascript">
<!-- Hide script from non-script-friendly browsers
var n;
var a;
var h;
var w;
var bmi;
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 = w / (h*h);

if (bmi <= 19)
{
message = "Underweight";
}
else if (bmi >= 20 && bmi <= 25)
{
message = "Acceptable";
}
else if (bmi >= 26 && bmi <=30)
{
message = "Overweight";
}
else if (bmi >= 31)
{
message = "Obese";
}
else
{
message = "Error!";
}

content = ("<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(content);
}
// stop hiding the script-->
</script>
</body>
</html>[/code]


it had simple mistakes , after i correct it , it works with me and my bmi was acceptable :cheesy:
"give only what u willing to receive "
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:07 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC