📁 File Manager
Editing:
/home/u845030939/public_html/bmi.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>BMI Calculator</title> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <style> body { font-family: Arial, sans-serif; background: linear-gradient(to right, #87CEEB, #32CD32); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .container { background: #fff; padding: 20px; border-radius: 15px; box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2); text-align: center; width: 350px; } h2 { color: #2E8B57; } input, select { width: 90%; padding: 10px; margin: 10px 0; border: 1px solid #ccc; border-radius: 5px; } .gender { display: flex; justify-content: center; gap: 20px; margin-bottom: 15px; } .gender input { width: auto; } button { background: #32CD32; color: white; border: none; padding: 10px; width: 100%; border-radius: 5px; cursor: pointer; font-size: 16px; } button:hover { background: #2E8B57; } .chart-container { position: relative; width: 100%; height: 250px; margin-top: 20px; } canvas { width: 100% !important; height: 100% !important; } </style> </head> <body> <div class="container"> <h2>BMI Calculator</h2> <input type="number" id="age" placeholder="Enter Age" required> <div class="gender"> <label><input type="radio" name="gender" value="male" checked> Male</label> <label><input type="radio" name="gender" value="female"> Female</label> </div> <input type="number" id="height" placeholder="Height (cm)" required> <input type="number" id="weight" placeholder="Weight (kg)" required> <button onclick="calculateBMI()">Calculate BMI</button> <h3>Your BMI is: <span id="bmi-value">0.00</span></h3> <div class="chart-container"> <canvas id="bmiChart"></canvas> </div> </div> <script> function calculateBMI() { let height = document.getElementById("height").value / 100; let weight = document.getElementById("weight").value; let bmi = (weight / (height * height)).toFixed(1); document.getElementById("bmi-value").innerText = bmi; updateChart(bmi); } function updateChart(bmi) { let ctx = document.getElementById("bmiChart").getContext("2d"); if (window.bmiChartInstance) { window.bmiChartInstance.destroy(); } window.bmiChartInstance = new Chart(ctx, { type: 'doughnut', data: { labels: ["Underweight", "Normal", "Overweight", "Obese"], datasets: [{ data: [bmi < 18.5 ? bmi : 0, (bmi >= 18.5 && bmi < 25) ? bmi : 0, (bmi >= 25 && bmi < 30) ? bmi : 0, bmi >= 30 ? bmi : 0], backgroundColor: ["#FFD700", "#32CD32", "#FFA500", "#FF4500"] }] }, options: { responsive: true, maintainAspectRatio: false, } }); } </script> </body> </html>
Save
Cancel