BMI Calculator in GF
August 7, 2025 · AI Conversations
– We should then have an answer field which displays their BMI and is calculating their BMI based on the weight and height (i.e. weight (kg)/ height (m)*2). Therefore the system should know to convert their weight to kg if entered in stones and pounds and their height to m, depending on the metrics entered to calculate their BMI.
In gravity form
—
### ✅ **Step-by-step Implementation**
#### 1. **Create Fields in Gravity Forms**
1. **Weight Unit Selector (Radio or Drop-down)**
– Label: `Select Weight Unit`
– Type: Drop-down
– Choices:
– Kilograms (kg)
– Stones & Pounds
2. **Weight Input Fields**
– **Weight in kg**
– Label: `Weight (kg)`
– Type: Number
– Enable Conditional Logic: Show **if Weight Unit is Kilograms**
– **Weight in stones**
– Label: `Weight (stones)`
– Type: Number
– Enable Conditional Logic: Show **if Weight Unit is Stones & Pounds**
– **Weight in pounds**
– Label: `Weight (pounds)`
– Type: Number
– Enable Conditional Logic: Show **if Weight Unit is Stones & Pounds**
3. **Height Unit Selector**
– Label: `Select Height Unit`
– Type: Drop-down
– Choices:
– Centimeters (cm)
– Feet & Inches
4. **Height Input Fields**
– **Height in cm**
– Label: `Height (cm)`
– Type: Number
– Enable Conditional Logic: Show **if Height Unit is Centimeters**
– **Height in feet**
– Label: `Height (feet)`
– Type: Number
– Enable Conditional Logic: Show **if Height Unit is Feet & Inches**
– **Height in inches**
– Label: `Height (inches)`
– Type: Number
– Enable Conditional Logic: Show **if Height Unit is Feet & Inches**
5. **BMI Output Field**
– Label: `Your BMI`
– Type: Calculation
– Use merge tags and logic below (we’ll customize this next).
—
### 🧮 **BMI Calculation Logic**
Since BMI = weight (kg) / (height in meters)^2
We need to convert:
– **Stones + pounds → kg**
`(stones * 6.35029) + (pounds * 0.453592)`
– **Feet + inches → meters**
`((feet * 12) + inches) * 0.0254`
– **cm → meters**
`cm / 100`
—
### 🧠 **Smart Calculation using Gravity Forms Calculation Field**
Use conditional merge tags in the **BMI Calculation field** with Gravity Forms’ conditional logic.
Example formula (pseudo-logic; actual logic will depend on field IDs):
IF Weight Unit = "Kilograms" AND Height Unit = "Centimeters":
BMI = {Weight_kg:1} / (({Height_cm:2} / 100)^2)
IF Weight Unit = "Stones & Pounds" AND Height Unit = "Feet & Inches":
BMI = (({Weight_stone:3} * 6.35029) + ({Weight_pound:4} * 0.453592)) / (((( {Height_feet:5} * 12 ) + {Height_inch:6}) * 0.0254)^2)
➡ You can break these into multiple **hidden number fields**:
– One for `weightInKg`
– One for `heightInM`
– Final **BMI field** can then do:
`weightInKg / (heightInM^2)`
—
### 💡 Tips
– Use **Gravity Perks GP Conditional Logic Dates** plugin if you need more advanced conditional calculations.
– Label fields clearly so users know which units they are entering.
– Add description texts like "Enter only numbers".
—
### ✅ Example Field Mapping (assuming field IDs):
| Field | Field ID |
|——-|———-|
| Weight Unit | `1` |
| Weight (kg) | `2` |
| Weight (stones) | `3` |
| Weight (pounds) | `4` |
| Height Unit | `5` |
| Height (cm) | `6` |
| Height (feet) | `7` |
| Height (inches) | `8` |
| Hidden Weight in kg | `9` |
| Hidden Height in meters | `10` |
| BMI Output | `11` |
—
Would you like me to generate **custom JavaScript** that auto-converts the fields in Gravity Forms instead of using hidden calculated fields?
—
### ✅ Step 1: Add Fields to Gravity Form
#### **1. Weight Unit Selector**
– Type: Drop-down
– Label: `Select Weight Unit`
– Choices:
– Kilograms (value: kg)
– Stones & Pounds (value: stlb)
– **Field ID: `1`**
—
#### **2. Weight Inputs**
– **Weight (kg)**
– Type: Number
– ID: `2`
– Conditional Logic: Show if **Field 1 = Kilograms**
– **Weight (stones)**
– Type: Number
– ID: `3`
– Conditional Logic: Show if **Field 1 = Stones & Pounds**
– **Weight (pounds)**
– Type: Number
– ID: `4`
– Conditional Logic: Show if **Field 1 = Stones & Pounds**
—
#### **3. Height Unit Selector**
– Type: Drop-down
– Label: `Select Height Unit`
– Choices:
– Centimeters (value: cm)
– Feet & Inches (value: ftin)
– **Field ID: `5`**
—
#### **4. Height Inputs**
– **Height (cm)**
– Type: Number
– ID: `6`
– Conditional Logic: Show if **Field 5 = Centimeters**
– **Height (feet)**
– Type: Number
– ID: `7`
– Conditional Logic: Show if **Field 5 = Feet & Inches**
– **Height (inches)**
– Type: Number
– ID: `8`
– Conditional Logic: Show if **Field 5 = Feet & Inches**
—
### ✅ Step 2: Add Calculation Fields (Hidden)
#### **5. Weight in kg (hidden)**
– Type: Number
– ID: `9`
– Visibility: Hidden
– Calculation Logic:
if({1} = "kg", {2}, ({3} * 6.35029) + ({4} * 0.453592))
—
#### **6. Height in meters (hidden)**
– Type: Number
– ID: `10`
– Visibility: Hidden
– Calculation Logic:
if({5} = "cm", {6} / 100, (({7} * 12) + {8}) * 0.0254)
—
### ✅ Step 3: Final BMI Calculation Field
#### **7. Your BMI**
– Type: Number
– ID: `11`
– Label: `Your BMI`
– **Calculation Formula**:
{9} / ({10} * {10})
—
### ✅ Optional Styling / Descriptions
– Add descriptions to fields like:
– “Enter weight in kilograms”
– “Enter height in centimeters”
– “Stones and pounds will be converted automatically”
– You may want to **round BMI** using JavaScript or CSS for cleaner output.
—
### ✅ Done!
Your Gravity Form now:
– Accepts weight and height in **different unit systems**
– Converts them automatically in the background
– Shows accurate **BMI** with proper logic
—
Would you like a **ready-to-import Gravity Forms JSON** file for this setup?
—
### 🔢 Example 1: **Weight in Kilograms**, Height in **Centimeters**
– **Weight**: 70 kg
– **Height**: 175 cm
**Convert height to meters**:
175 ÷ 100 = **1.75 m**
**BMI formula**:
70 ÷ (1.75 × 1.75) = **22.86**
✅ **BMI = 22.86**
—
### 🔢 Example 2: **Weight in Stones and Pounds**, Height in **Feet and Inches**
– **Weight**: 11 stones 0 pounds
– **Height**: 5 feet 9 inches
**Convert weight to kg**:
(11 × 6.35029) + (0 × 0.453592) = **69.85 kg**
**Convert height to meters**:
(5 × 12 + 9) = 69 inches
69 × 0.0254 = **1.7526 m**
**BMI formula**:
69.85 ÷ (1.7526 × 1.7526) = **22.73**
✅ **BMI = 22.73**
—
### 🔢 Example 3: **Weight in Stones and Pounds**, Height in **Centimeters**
– **Weight**: 10 stones 5 pounds
– **Height**: 160 cm
**Convert weight to kg**:
(10 × 6.35029) + (5 × 0.453592) = 63.50 + 2.27 = **65.77 kg**
**Convert height to meters**:
160 ÷ 100 = **1.60 m**
**BMI formula**:
65.77 ÷ (1.60 × 1.60) = **25.70**
✅ **BMI = 25.70**
—
Let me know if you’d like the same examples implemented in a real **Gravity Forms live calculator** or need a downloadable form file.
—
### ✅ Updated Plan for Stones and Pounds with "st" and "lg" Options
#### 1. **Weight Unit Selector**
– **Field Type**: Drop-down
– **Label**: *Select Weight Unit*
– **Choices**:
– Kilograms (value: `kg`)
– Stones and Pounds (value: `stlb`) ✅
—
#### 2. **Weight Input for Stones (st)**
– **Field Type**: Number
– **Label**: *Weight (st)*
– **Field ID**: `3`
– **Show if** Weight Unit = `stlb`
—
#### 3. **Weight Input for Pounds (lg)**
– **Field Type**: Number
– **Label**: *Weight (lg)* or *Pounds (lb)*
– **Field ID**: `4`
– **Show if** Weight Unit = `stlb`
You can add a small description like:
> "Enter additional pounds (e.g., 5 if weight is 10 st 5 lb)"
—
### 🧠 Conversion Formula Example
Let’s say the user enters:
– **10 st**
– **6 lg (pounds)**
#### Convert to kg:
(10 * 6.35029) + (6 * 0.453592) = 63.50 + 2.72 = 66.22 kg
—
### ✅ Gravity Forms Calculation Field (Hidden)
Create a **hidden field** to calculate **Weight in kg**:
if({1} = "kg", {2}, ({3} * 6.35029) + ({4} * 0.453592))
Where:
– `{1}` = Unit selector
– `{2}` = Direct kg input
– `{3}` = Stones
– `{4}` = Pounds (lg)
—
### ✅ Sample Inputs and Result
| Stones (st) | Pounds (lg) | Resulting Weight (kg) |
|————-|————-|————————|
| 12 | 0 | 76.20 kg |
| 10 | 4 | 65.27 kg |
| 8 | 10 | 56.25 kg |
—
Would you like me to export this setup as a Gravity Forms **.json file** ready to import into your site?
—
### ✅ Goal
When **“Stones and Pounds”** is selected in the **Weight Unit** dropdown, show:
– 🪨 One input field labeled **“Stones (st)”**
– ⚖️ One input field labeled **“Pounds (lb or lg)”**
—
### ✅ Gravity Forms Setup
#### 🔹 **Step 1: Weight Unit Selector**
– **Field Type**: Drop-down
– **Label**: `Select Weight Unit`
– **Choices**:
– Kilograms (value: `kg`)
– Stones and Pounds (value: `stlb`)
– **Field ID**: `1`
—
#### 🔹 **Step 2: Weight Input for Kilograms**
– **Field Type**: Number
– **Label**: `Weight (kg)`
– **Field ID**: `2`
– **Conditional Logic**: Show if Field `1` is `kg`
—
#### 🔹 **Step 3: Weight Input for Stones (st)**
– **Field Type**: Number
– **Label**: `Weight (Stones)`
– **Field ID**: `3`
– **Conditional Logic**: Show if Field `1` is `stlb`
—
#### 🔹 **Step 4: Weight Input for Pounds (lg)**
– **Field Type**: Number
– **Label**: `Additional Pounds`
– **Field ID**: `4`
– **Conditional Logic**: Show if Field `1` is `stlb`
💡 *Add description below the field:*
> Example: If your weight is 10 st 6 lb, enter 10 and 6.
—
#### 🔹 **Step 5: Hidden Field to Convert to KG**
– **Field Type**: Number (Hidden)
– **Label**: `Weight in KG (calculated)`
– **Field ID**: `9`
– **Formula**:
if({1} = "kg", {2}, ({3} * 6.35029) + ({4} * 0.453592))
—
### ✅ Sample Output
If user selects “Stones and Pounds” and enters:
– Stones (st): `10`
– Pounds (lg): `5`
The calculated weight will be:
(10 * 6.35029) + (5 * 0.453592) = 63.5029 + 2.26796 = **65.77 kg**
—
Let me know if you want:
– This full setup exported as a **Gravity Forms JSON file**, or
– A similar logic for height (feet/inches) with meters conversion.