function ccBM_bmi_calc(lbs, ins) { var f = document.forms.ccBM_bmiForm; var w_v = f.w_v.value*1; var w_u = f.w_u.options[f.w_u.selectedIndex].value; var h_ft = f.h_ft.options[f.h_ft.selectedIndex].value; var h_in = f.h_in.options[f.h_in.selectedIndex].value; var h_v = f.h_v.value*1; var h_u = f.h_u.options[f.h_u.selectedIndex].value; var err = ''; if(!w_v || (w_v<35 || w_v>600)) { err += 'Weight value is missing or invalid.'+"\n"; } if(h_v) { if(!ccBM_is_n(h_v)) { err += 'Height must be a number.'+"\n"; } if(h_ft || f.h_in.selectedIndex>0) { err += 'Please choose only one method for height (ft+in, OR inches/cm).'; } } else { if(!ccBM_is_n(h_ft) || f.h_in.selectedIndex==0) { err += 'Height value is missing or invalid.'; } } if(err) { alert(err); return false; } if(w_u=='kg') { w_v *= 2.20462262; } if(h_v) { if(h_u=='cm') { h_v *= 0.393700787; } } else { h_v = (h_ft*12) + (1*h_in); } var bmi = Math.round( (w_v/(h_v*h_v))*703*10 )/10; var txt = ''; if(bmi<16.5) { txt = 'severely underweight'; } else if(bmi>=16.5 && bmi<18.5) { txt = 'underweight'; } else if(bmi>=18.5 && bmi<25) { txt = 'normal'; } else if(bmi>=25 && bmi<30) { txt = 'overweight'; } else { txt = 'obese'; } txt = 'Your bmi is '+bmi+'. You are considered '+txt+'.'; document.getElementById('ccBM_lyr_bmi').innerHTML = txt; } function ccBM_is_n(n) { if( isNaN(n) || n==null || n.length==0 ) { return false; } n=n+""; if( n.search(/\s+/)!=-1 ) { return false; } return true; } if( document.layers && !document.getElementById ) { document.write( 'Sorry, to view the BMI calculator you must use a newer browser.
'); } else { if(typeof(ccBM_ttl)=='undefined') { var ccBM_ttl = 1; } document.write( '' ); }