Q:

BMI calculation syntax with javascript inside dynamics

I'd like to create a simple BMI calculator (MS Dynamics 2011)
I have 3 fields:
1: persons height (precision 2 - decimal formatted text box)
2.  persons weight (precision 2 - decimal formatted text box)
3.  BMI result - This field will display the BMI result. ( also precision 2 - decimal)

I believe I need to check the oncreate event on both fields 1 & 2, to launch a javascript function to carry out the calculation. 
However, I am very new to both dynamics and java-script, and need some help. 
I think something along these lines could be close.   Can someone assist? 
function BMICheck()
{
var Bmiresult = weight/(height/100*height/100);
Xrm. Page.getAttribute("new_bmiresulttextbox").setValue((Math.round(Bmiresult*100)/100).toString(    ));

}

I think I understand the logic OK, syntax is my main issue. 
Thanks! 
Updated answer with javascript:
function BMICheck()
{

var Bmival = Xrm. Page.getAttribute("crm_heightbox_decimal")/("crm_weightbox_decimal")/100*("crm_weightbox_decimal")/100);
 Xrm. Page.getAttribute("crm_bmiresultbox").setValue((Math.round(Bmival*100)/100));

 }

A:

The javascript is ok, except for ToString as Daryl already pointed out. 
I would add a check for height and weight to prevent null values (the check if is a positive number can be avoided if the fields have a minimum value setting greater than 0.00)
function BMICheck()
{
    var weight = Xrm. Page.getAttribute("new_weight").getValue();
    var height = Xrm. Page.getAttribute("new_height").getValue();
    if (weight ! = null & height ! = null) {
        var bmi = weight/(height/100*height/100);
        Xrm. Page.getAttribute("new_bmi").setValue(Math.round(bmi*100)/100);
    }
    else {
        alert("Need to insert Weight and Height!"); 
    }
}

