Ideal weight calculator

This calculator has multiple calculated fields and works together with the free Conditional Fields for Contact Form 7 plugin to branch into different subsections of the form conditionally.





    Source code for this form:

    <label>Are you a:
    [radio sex "Woman" "Man"]</label>
    
    [group woman]
      <label>Units:
      [radio w_units "US (feet, inches, lbs)" "Metric (cm, kg)"]</label>
    
      [group w_us]
        <label>Height:
        [number w_feet min:0 max:10 "5"] ft [number w_inches min:0 max:11 "10"] in</label>
        [calculation w_total_inches cf7-hide min:0 "w_feet*12+w_inches"] [calculation w_over_5ft min:0 cf7-hide "w_total_inches-60"] [calculate_button calculate_button-1 "Calculate"]
        <div id="w_us_result" style="display: none;">
          Based on the Robinson formula (1983), your ideal weight is [calculation robinson_woman_us min:0 precision:1 "(49+1.7*w_over_5ft)*2.20462"] lbs
          Based on the Miller formula (1983), your ideal weight is [calculation miller_woman_us min:0 precision:1 "(53.1+1.36*w_over_5ft)*2.20462"] lbs
          Based on the Devine formula (1974), your ideal weight is [calculation devine_woman_us min:0 precision:1 "(45.5+2.3*w_over_5ft)*2.20462"] lbs
          Based on the Hamwi formula (1964), your ideal weight is [calculation hamwi_woman_us min:0 precision:1 "(45.5+2.2*w_over_5ft)*2.20462"] lbs
          Based on the healthy BMI recommendation, your recommended weight is [calculation bmi_woman_us_lower min:0 precision:1 "18.5 * (w_total_inches ^ 2) / 703"] lbs - [calculation bmi_woman_us_upper min:0 precision:1 "25 * w_total_inches ^ 2 / 703"] lbs
        </div>
      [/group]
    
      [group w_metric]
        <label>Height:
        [number w_cm min:0 max:300 "175"] cm</label>
        [calculation w_over_5ft_m min:0 cf7-hide "w_cm/2.54-60"] [calculate_button calculate_button-2 "Calculate"]
        <div id="w_metric_result" style="display: none;">
          Based on the Robinson formula (1983), your ideal weight is [calculation robinson_woman_m min:0 precision:1 "(49+1.7*w_over_5ft_m)"] kg
          Based on the Miller formula (1983), your ideal weight is [calculation miller_woman_m min:0 precision:1 "(53.1+1.36*w_over_5ft_m)"] kg
          Based on the Devine formula (1974), your ideal weight is [calculation devine_woman_m min:0 precision:1 "(45.5+2.3*w_over_5ft_m)"] kg
          Based on the Hamwi formula (1964), your ideal weight is [calculation hamwi_woman_m min:0 precision:1 "(45.5+2.2*w_over_5ft_m)"] kg
          Based on the healthy BMI recommendation, your recommended weight is [calculation bmi_woman_m_lower min:0 precision:1 "18.5 * (w_cm/100) ^ 2"] kg - [calculation bmi_woman_m_upper min:0 precision:1 "25 * (w_cm/100) ^ 2"] kg
        </div>
      [/group]
    [/group]
    
    [group man]
      <label>Units:
      [radio m_units "US (feet, inches, lbs)" "Metric (cm, kg)"]</label>
    
      [group m_us]
        <label>Height:
        [number m_feet min:0 max:10 "5"] ft [number m_inches min:0 max:11 "10"] in</label>
        [calculation m_total_inches cf7-hide min:0 "m_feet*12+m_inches"] [calculation m_over_5ft min:0 cf7-hide "m_total_inches-60"] [calculate_button calculate_button-3 "Calculate"]
        <div id="m_us_result" style="display: none;">
          Based on the Robinson formula (1983), your ideal weight is [calculation robinson_man_us min:0 precision:1 "(52+1.9*w_over_5ft)*2.20462"] lbs
          Based on the Miller formula (1983), your ideal weight is [calculation miller_man_us min:0 precision:1 "(56.2+1.41*w_over_5ft)*2.20462"] lbs
          Based on the Devine formula (1974), your ideal weight is [calculation devine_man_us min:0 precision:1 "(50.0+2.3*w_over_5ft)*2.20462"] lbs
          Based on the Hamwi formula (1964), your ideal weight is [calculation hamwi_man_us min:0 precision:1 "(48.0+2.7*w_over_5ft)*2.20462"] lbs
          Based on the healthy BMI recommendation, your recommended weight is [calculation bmi_man_us_lower min:0 precision:1 "18.5 * (m_total_inches ^ 2) / 703"] lbs - [calculation bmi_man_us_upper min:0 precision:1 "25 * m_total_inches ^ 2 / 703"] lbs
        </div>
      [/group]
    
      [group m_metric]
        <label>Height:
        [number m_cm min:0 max:300 "175"] cm</label>
        [calculation m_over_5ft_m min:0 cf7-hide "m_cm/2.54-60"] [calculate_button calculate_button-4 "Calculate"]
        <div id="m_metric_result" style="display: none;">
          Based on the Robinson formula (1983), your ideal weight is [calculation robinson_man_m min:0 precision:1 "(52+1.9*m_over_5ft_m)"] kg
          Based on the Miller formula (1983), your ideal weight is [calculation miller_man_m min:0 precision:1 "(56.2+1.41*m_over_5ft_m)"] kg
          Based on the Devine formula (1974), your ideal weight is [calculation devine_man_m min:0 precision:1 "(50.0+2.3*m_over_5ft_m)"] kg
          Based on the Hamwi formula (1964), your ideal weight is [calculation hamwi_man_m min:0 precision:1 "(48.0+2.7*m_over_5ft_m)"] kg
          Based on the healthy BMI recommendation, your recommended weight is [calculation bmi_man_m_lower min:0 precision:1 "18.5 * (m_cm/100) ^ 2"] kg - [calculation bmi_man_m_upper min:0 precision:1 "25 * (m_cm/100) ^ 2"] kg
        </div>
      [/group]
    [/group]
    <script>
    jQuery('div[data-id="w_us"] .wpcf7-calculate_button').click(function() {
      jQuery('#w_us_result').show();
    });
    jQuery('div[data-id="w_metric"] .wpcf7-calculate_button').click(function() {
      jQuery('#w_metric_result').show();
    });
    jQuery('div[data-id="m_us"] .wpcf7-calculate_button').click(function() {
      jQuery('#m_us_result').show();
    });
    jQuery('div[data-id="m_metric"] .wpcf7-calculate_button').click(function() {
      jQuery('#m_metric_result').show();
    });
    </script>