Hi Guys I have the following code for html and php. when i click on the button to calculate bmi it doesnt work.... can someone please help it is urgent...
Heres html code:
<html>
<head>
<script type="text/javascript">
function Calculate(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","bmi.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form onsubmit="Calculate(str); return false;">
<h1> Body Mass Index Ajax applicaiton </h1>
<p>Weight (kg): <input id="weight" type="text" /><br /></p>
<p>Height (m): <input id="height" type="text" /><br /></p>
<input type="submit" value="Calculate Body Mass" />
</form>
<br /><br />
<p>Your BMI is: <span id="bmi"></span></p>
</body>
php code:
<?php
$height = $_GET[‘height’];
$weight = $_GET[‘weight’];
$bmi = $weight / ($height * $height);
echo $bmi;
?>