A little java-script from the JQuery library will help us perform our BMI calculation. The following should be added to the LEFT_ITEM_TEXT field within your CRF Excel template:

<script src=”includes/jmesa/jquery.min.js”>// for OC versions before 3.1.4, use jquery-1.3.2.min.js !</script><script>
$.noConflict();
jQuery(document).ready(function($)
{
var heightField = $(“#Height”).parent().parent().find(“input”);
var weightField = $(“#Weight”).parent().parent().find(“input”);
var bmiField = $(“#BMI”).parent().parent().find(“input”);

 

function getBMI(height1, weight1)
{
//calculate weight portion
var weightLBS = weight1*703;
//calculate height portion
var heightINCH = height1*height1;
//divide weight by height
var bmi = (weightLBS/heightINCH);
//calculate the days
var finalBMI = Math.round(bmi*10)/10;
if (isNaN(finalBMI))
{
return 0;  
}
else
{
return finalBMI;
}
}

function calcBMI()

{
//calculate the BMI given the height and weight.
var bmi = getBMI(heightField.val(), weightField.val());
//write the calculated value to the field.
if (bmiField.val() != bmi)
{
bmiField.val(bmi);
bmiField.change();
}
};
//Calculate will fire upon save or when the calculation button is clicked.
$(“#srl”).focus(function(){ calcBMI(); });
$(“#srh”).focus(function(){ calcBMI(); });
$(“#calculate1”).click(function(){ calcBMI(); });
})
</script>