function calc()
{
	var wt = document.bmi.wg.value;
	var ht = document.bmi.ht.value;
	
	var op=document.bmi.opt1.value;
	
	//SI value
	var h = ht/100;
	var si = Math.round((wt/(h*h))*100)/100;
	document.bmi.si.value = si;
	
	//US value
	var lb = wt*2.2;
	var ic = ht*0.39;
	var us = Math.round((703*(lb/(ic * ic)))*100)/100;
	document.bmi.us.value = us;
	
	//UK value
	var uk = Math.round((6.35*si)*100)/100;
	document.bmi.uk.value = uk;
	
	//If value is not given for weight
	if(wt=="")
	{
		alert("Enter the value for weight");
	}

	//If weight is less than 10
	else if(wt<=10)
	{
		document.bmi.si.value = 0;
		document.bmi.us.value = 0;
		document.bmi.uk.value = 0;
		alert("Weight should be greater than 10kgs");
	}
	
	//If weight is pounds and less than 22lbs
	else if(op=="pounds" && wt<=22)
	{
		document.bmi.si.value = 0;
		document.bmi.us.value = 0;
		document.bmi.uk.value = 0;
		alert("Weight should be greater than 22lbs");
	}
	
	//If given height is less than 33cms
	else if(ht<33)
	{
		document.bmi.si.value = 0;
		document.bmi.us.value = 0;
		document.bmi.uk.value = 0;
		alert("Height should be taller than 33cms");
	}
	else if(op=="pounds")
	{
		document.bmi.si.value=Math.round((si/2.2)*100)/100;
		document.bmi.us.value=Math.round((us/2.2)*100)/100;
		document.bmi.uk.value=Math.round((uk/2.2)*100)/100;
	}
	var d = "Your category is "
	if(si<15)
	{
		document.bmi.desc.value= d + "Starvation";
	}
	else if(si>15 && si<=18.5)
	{
		document.bmi.desc.value= d + "Underweight";
	}
	else if(si>18.5 && si<=25)
	{	
		document.bmi.desc.value= d + "Normal";	
	}
	else if(si>25 && si<=30)
	{
		document.bmi.desc.value=d + "Overweight";
	}
	else if(si>30)
	{
		document.bmi.desc.value=d + "Obese";
	}
}


function conv(aa)//Height conversion
{
	var ft=0, inc=0, ht=0;
	if(aa==1 || aa==2)
	{
		ft = document.bmi.opt2.value;
		inc = document.bmi.opt3.value;
		var ss = ft*12;
		var tot = ss+parseInt(inc);
       	var val= tot*2.54;
		document.bmi.ht.value = Math.round(val);
	}

	else{
		ht = document.bmi.ht.value;
		if(ht!="")
		{
			var cm=Math.round(ht/2.54);
			var div=parseInt(cm/12);
			var md=cm%12;
			document.bmi.opt2.value=div;
			document.bmi.opt3.value=md;
		}
         }

}


function unit()  //Weight conversion
{
	var pp=document.bmi.opt1.value;
	var ww = document.bmi.wg.value;
	
	//Kilogram to pounds
	if(pp=="pounds")	
	{
		document.bmi.wg.value = Math.round((ww*2.2)*100)/100;
	}

	//Pounds to kilograms
	else
	{
		document.bmi.wg.value=Math.round(ww/2.2);
	}
}

<!-- Begin
function mod(div,base) {
return Math.round(div - (Math.floor(div/base)*base));
}
function calcBmi() {
var w = document.bmi.weight.value * 1;
var HeightFeetInt = document.bmi.htf.value * 1;
var HeightInchesInt = document.bmi.hti.value * 1;
HeightFeetConvert = HeightFeetInt * 12;
h = HeightFeetConvert + HeightInchesInt;
displaybmi = (Math.round((w * 703) / (h * h)));
var rvalue = true;
if ( (w <= 35) || (w >= 500)  || (h <= 48) || (h >= 120) ) {
alert ("Invalid data.  Please check and re-enter!");
rvalue = false;
}
if (rvalue) {
if (HeightInchesInt > 11) {
reminderinches = mod(HeightInchesInt,12);
document.bmi.hti.value = reminderinches;
document.bmi.htf.value = HeightFeetInt + 
((HeightInchesInt - reminderinches)/12);
document.bmi.answer.value = displaybmi;
}
if (displaybmi <19) 
document.bmi.comment.value = "Underweight";
if (displaybmi >=19 && displaybmi <=25) 
document.bmi.comment.value = "Desirable";
if (displaybmi >=26 && displaybmi <=29) 
document.bmi.comment.value = "prone to health risks";
if (displaybmi >=30 && displaybmi <=40) 
document.bmi.comment.value = "Obese";
if (displaybmi >40) 
document.bmi.comment.value = "Extremely obese";
document.bmi.answer.value = displaybmi; }
return rvalue;
}
//  End -->

// Body Mass Index Calculator
// copyright 28th April 2006, by Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
function valButton(btn) {var cnt = -1;for (var i=btn.length-1; i > -1; i--) {   if (btn[i].checked) {cnt = i; i = -1;}}if (cnt > -1) return btn[cnt].value;else return null;}function stripBlanks(fld) {var result = "";var c = 0;for (i=0; i < fld.length; i++) {if (fld.charAt(i) != " " || c > 0) {result += fld.charAt(i);if (fld.charAt(i) != " ") c = result.length;}}return result.substr(0,c);}function calc(thisform) {var d = valButton(thisform.d);if (d == null) {alert("You must choose centimetres/kg or inches/lb");return false;}cv = d.split(',');;var h = stripBlanks(thisform.h.value);if (h == '') {alert("You must enter your height");thisform.h.focus();return false;}if (h != Number(h) || (h = Number(h*cv[0]/100)) < 1 || h > 2.5) {alert("Invalid height entered");thisform.h.focus();return false;}var w = stripBlanks(thisform.w.value);if (w == '') {alert("You must enter your weight");thisform.w.focus();return false;}if (w != Number(w) || (w = Number(w/cv[1])) < 25 || w > 250) {alert("Invalid weight entered");thisform.w.focus();return false;} thisform.f.value = Math.round(w / (h*h)*100)/100;}