function ideal(form) {
//man,kg,cm
if ((form.sex[0].checked)&&(form.wt2.options[0].selected ==true)&&
	(form.ht2.options[0].selected ==true)) {   
var sex = 50;
var wt = form.wt.value;
var x = (form.ht.value - 152.4) * 0.3937;
var IBW = x * 2.3 + sex;
var ABW = 0.4*(wt - IBW) + IBW;
var per = IBW * 0.30 + IBW;
form.IBW.value = Math.round(10*IBW)/10 + " kg";
form.ABW.value = Math.round(10*ABW)/10 + " kg";
form.per.value = Math.round(10*per)/10 + " kg";

}
//man,lb,in
else if
	((form.sex[0].checked)&&(form.wt2.options[1].selected ==true)&&
	(form.ht2.options[1].selected ==true)) {   
var sex = 50;
var wt = form.wt.value / 2.2;
var x = form.ht.value -60;
var IBW = x * 2.3 + sex;
var ABW = 0.4*(wt - IBW) + IBW;
var per = IBW * 0.3 + IBW;
form.IBW.value = Math.round(10*(IBW*2.2))/10 + " lb";
form.ABW.value = Math.round(10*(ABW*2.2))/10 + " lb";
form.per.value = Math.round(10*(per*2.2))/10 + " lb";
}
//man,kg,in
else if
	((form.sex[0].checked)&&(form.wt2.options[0].selected ==true)&&
	(form.ht2.options[1].selected ==true)) {   
var sex = 50;
var wt = form.wt.value;
var x = form.ht.value -60;
var IBW = x * 2.3 + sex;
var ABW = 0.4*(wt - IBW) + IBW;
var per = IBW * 0.3 + IBW;
form.IBW.value = Math.round(10*IBW)/10 + " kg";
form.ABW.value = Math.round(10*ABW)/10 + " kg";
form.per.value = Math.round(10*per)/10 + " kg";
}
//man,lb,cm
else if
	((form.sex[0].checked)&&(form.wt2.options[1].selected ==true)&&
	(form.ht2.options[0].selected ==true)) {   
var sex = 50;
var wt = form.wt.value /2.2;
var x = (form.ht.value - 152.4) * 0.3937;
var IBW = x * 2.3 + sex;
var ABW = 0.4*(wt - IBW) + IBW;
var per = IBW * 0.3 + IBW;
form.IBW.value = Math.round(10*IBW)/10 +" kg";
form.ABW.value = Math.round(10*ABW)/10 +" kg";
form.per.value = Math.round(10*per)/10 +" kg";
}

//woman,kg,cm
else if 
	((form.sex[1].checked)&&(form.wt2.options[0].selected ==true)&&
	(form.ht2.options[0].selected ==true)) {   
var sex = 45.5;
var wt = form.wt.value;
var x = (form.ht.value - 152.4) * 0.3937;
var IBW = x * 2.3 + sex;
var ABW = 0.4*(wt - IBW) + IBW;
var per = IBW * 0.3 + IBW;
form.IBW.value = Math.round(10*IBW)/10 + " kg";
form.ABW.value = Math.round(10*ABW)/10 + " kg";
form.per.value = Math.round(10*per)/10 + " kg";
}
//woman,lb,in
else if
	((form.sex[1].checked)&&(form.wt2.options[1].selected ==true)&&
	(form.ht2.options[1].selected ==true)) {   
var sex = 45.5;
var wt = form.wt.value / 2.2;
var x = form.ht.value -60;
var IBW = x * 2.3 + sex;
var ABW = 0.4*(wt - IBW) + IBW;
var per = IBW * 0.3 + IBW;
form.IBW.value = Math.round(10*(IBW*2.2))/10 + " lb";
form.ABW.value = Math.round(10*(ABW*2.2))/10 + " lb";
form.per.value = Math.round(10*(per*2.2))/10 + " lb";
}
//woman,kg,in
else if
	((form.sex[1].checked)&&(form.wt2.options[0].selected ==true)&&
	(form.ht2.options[1].selected ==true)) {   
var sex = 45.5;
var wt = form.wt.value;
var x = form.ht.value -60;
var IBW = x * 2.3 + sex;
var ABW = 0.4*(wt - IBW) + IBW;
var per = IBW * 0.3 + IBW;
form.IBW.value = Math.round(10*IBW)/10 + " kg";
form.ABW.value = Math.round(10*ABW)/10 + " kg";
form.per.value = Math.round(10*per)/10 + " kg";
}
//woman,lb,cm
else if
	((form.sex[1].checked)&&(form.wt2.options[1].selected ==true)&&
	(form.ht2.options[0].selected ==true)) {   
var sex = 45.5;
var wt = form.wt.value /2.2;
var x = (form.ht.value - 152.4) * 0.3937;
var IBW = x * 2.3 + sex;
var ABW = 0.4*(wt - IBW) + IBW;
var per = IBW * 0.3 + IBW;
form.IBW.value = Math.round(10*IBW)/10 +" kg";
form.ABW.value = Math.round(10*ABW)/10 +" kg";
form.per.value = Math.round(10*per)/10 +" kg";
}

//alerts
if((form.wt.value==null)||(form.wt.value=="")||(isNaN(form.wt.value))){
alert('Please enter a weight with numbers only. Use a period for decimal place.');
form.wt.focus();
form.wt.select();
return false
}
//alert
if((form.ht.value==null)||(form.ht.value=="")||(isNaN(form.ht.value))){
alert('Please enter a height with numbers only. Use a period for decimal place.');
form.ht.focus();
form.ht.select();
return false
}
if(form.ht.value <60){
alert('Height must be more than 60 inches');
form.ht.focus();
form.ht.select();
return false
}
if((wt > per) && (!(parseInt(form.IBW.value) < 1))){
alert('Use ABW of ' + form.ABW.value + ' for dosing' +'\n' +
	'medications instead of IBW.');
}
if(parseInt(form.IBW.value) < 1){
alert('Are you sure height'
	+'\n' + '& wieght are correct?');
}
}
function meas(form) {
var fc=form.mea.value;
if (form.cfc[0].checked) {
var answer= fc * .39
}
else {
var answer=fc * 2.54
}
form.answer.value=Math.round(10*answer)/10;
//form validation--
var mea=form.mea.value;
//alert
if((mea==null)||(mea=="")||(isNaN(mea))){
alert('Please enter a legnth with numbers only. Use a period for decimal place.');
form.mea.focus();
form.mea.select();
return false
}
}
function weight(form) {
var fc=form.mea.value;
if (form.cfc[0].checked) {
var answer= fc / 2.2
}
else {
var answer=fc *2.2
}
form.answer.value=Math.round(10*answer)/10;
//form validation--
var mea=form.mea.value;
//alert
if((mea==null)||(mea=="")||(isNaN(mea))){
alert('Please enter a weight with numbers only. Use a period for decimal place.');
form.mea.focus();
form.mea.select();
return false
}
}



//copied functions

	// The main calculation function
function calcDCN (intWeight,intFeet,intInches,intAge,strGender) {

	// Gets Rate of Metabolism (BMR)
		// Step One: WeightSex
	var fltWM = intWeight * 6.2;
	var fltWW = intWeight * 4.4;
	
		// Step Two: Height, HeightSex
	var intHeight = intFeet * 12 + parseInt(intInches);
	var fltHM = intHeight * 12.7;
	var fltHW = intHeight * 4.7;
	
		// Step Three: AgeSex
	var fltAM = intAge * 6.8;
	var fltAW = intAge * 4.7;
	
		// Calculate: Basal Metabolic Rate
	var fltBMR;
	if (strGender == "male") {
		 fltBMR = ((fltWM + fltHM) - fltAM) + 66;
	} else {
		 fltBMR = ((fltWW + fltHW) - fltAW) + 655;
	}
	
	//  Gets Calories for Physical Activity, 
	//  (Energy for Digestion and Absorption), 
	//  and Total Energy Needs               
	var fltCPA = fltBMR;
	var fltTEN = fltBMR;
	
	// Write the result to the text box
	document.dcn.Result.value = parseInt(fltTEN);
	
}





	function ClearForm(form){

    form.weight.value = "";
    form.height.value = "";
    form.bmi.value = "";
    form.my_comment.value = "";

}

function bmi(weight, height) {

          bmindx=weight/eval(height*height);
          return bmindx;
}

function checkform(form) {

       if (form.weight.value==null||form.weight.value.length==0 || form.height.value==null||form.height.value.length==0){
            alert("\nPlease complete the form first");
            return false;
       }

       else if (parseFloat(form.height.value) <= 0||
                parseFloat(form.height.value) >=500||
                parseFloat(form.weight.value) <= 0||
                parseFloat(form.weight.value) >=500){
                alert("\nReally know what you're doing? \nPlease enter values again. \nWeight in kilos and \nheight in cm");
                ClearForm(form);
                return false;
       }
       return true;

}

function computeform(form) {

       if (checkform(form)) {

       yourbmi=Math.round(bmi(form.weight.value, form.height.value/100));
       form.bmi.value=yourbmi;

       if (yourbmi >40) {
          form.my_comment.value="You are grossly obese, consult your physician!";
       }

       else if (yourbmi >30 && yourbmi <=40) {
          form.my_comment.value="Umm... You are obese, want some liposuction?";
       }

       else if (yourbmi >27 && yourbmi <=30) {
          form.my_comment.value="You are very fat, do something before it's too late";
       }

       else if (yourbmi >22 && yourbmi <=27) {
          form.my_comment.value="You are fat, need dieting and exercise";
       }

       else if (yourbmi >=21 && yourbmi <=22) {
          form.my_comment.value="I envy you. Keep it up!!";
       }

       else if (yourbmi >=18 && yourbmi <21) {
          form.my_comment.value="You are thin, eat more.";
       }

       else if (yourbmi >=16 && yourbmi <18) {
          form.my_comment.value="You are starving. Go Find some food!";
       }

       else if (yourbmi <16) {
          form.my_comment.value="You're grossly undernourished, need hospitalization ";
       }

       }
       return;
}





<!-- Copyright 2006, Sandeep Gangadharan -->
<!--
function get_whr() {
 if (document.whr_calc.waist.value.length == 0) {
      alert('Waist field is empty!'); return false; }
 if (document.whr_calc.hip.value.length == 0) {
      alert('Hip field is empty!'); return false; }

 num1 = Math.pow(10, 2);
 document.whr_calc.result_whr.value = document.whr_calc.waist.value / document.whr_calc.hip.value;
 document.whr_calc.result_whr.value = Math.round(document.whr_calc.result_whr.value * num1) / num1;

 if (document.whr_calc.gender[0].checked) {
    if (document.whr_calc.result_whr.value <= 0.80) {
       document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Good and you fall in the Low Risk category!"; }
    if ((document.whr_calc.result_whr.value > 0.80) && (document.whr_calc.result_whr.value < 0.85)) {
       document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Acceptable and you fall in the Moderate Risk category!"; }
    if (document.whr_calc.result_whr.value >= 0.85) {
       document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Poor and you fall in the High Risk category!"; }
 }
 if (document.whr_calc.gender[1].checked) {
    if (document.whr_calc.result_whr.value <= 0.95) {
       document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Good and you fall in the Low Risk category!"; }
    if ((document.whr_calc.result_whr.value > 0.95) && (document.whr_calc.result_whr.value <= 1.00)) {
       document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Acceptable and you fall in the Moderate Risk category!"; }
    if (document.whr_calc.result_whr.value > 1.00) {
       document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Poor and you fall in the High Risk category!"; }
 }
}
//-->
