HTML CSS JS Projects
Project 2HTML · CSS · JS~40 min
BMI Calculator
Forms, validation, and calculated output
Track progress0/3 days
What you'll learn
<form>preventDefaultparseInt/parseFloatinnerHTMLCSS forms
- Build a styled form with selects and number inputs
- Read values on submit without reloading the page
- Convert height from feet/inches to meters
- Display BMI and a weight category
Lesson & examples
Read the code, then the explanation — try changing values before the project.
Handle form submit
document.getElementById("bmiForm").addEventListener("submit", function (e) {
e.preventDefault();
// read inputs and calculate...
});Height in meters
const heightInMeters = ((feet * 12) + inches) * 0.0254;
const bmi = weight / (heightInMeters * heightInMeters);Show result in the page
document.getElementById("result").innerHTML =
"Your BMI: " + bmi.toFixed(2) + "<br>Category: " + category;