function calculateBMI(event) {
    event.preventDefault();

    // Get form inputs
    const feet = parseFloat(document.getElementById('feet').value);
    const inches = parseFloat(document.getElementById('inches').value);
    const weight = parseFloat(document.getElementById('weight').value);

    // Convert height to total inches
    const heightInInches = (feet * 12) + inches;

    // BMI formula (weight in pounds and height in inches)
    const bmi = (weight * 703) / (heightInInches * heightInInches);

    // Display the calculated BMI
    document.getElementById('bmiResult').innerText = bmi.toFixed(2);

    // Clear previous highlights
    clearHighlight();

    // Highlight the corresponding BMI category
    if (bmi < 18.5) {
        document.getElementById('underweight').classList.add('highlight');
    } else if (bmi >= 18.5 && bmi <= 24.9) {
        document.getElementById('normal').classList.add('highlight');
    } else if (bmi >= 25 && bmi <= 29.9) {
        document.getElementById('overweight').classList.add('highlight');
    } else {
        document.getElementById('obese').classList.add('highlight');
    }

    return false;
}

// Function to clear previous highlight
function clearHighlight() {
    const categories = document.querySelectorAll('.bmi-category');
    categories.forEach(category => {
        category.classList.remove('highlight');
    });
}
