https://weightcalculator.my.canva.site/
<!doctype html>


Healthy Weight Calculator

Calculate your ideal weight range based on your age and height

This calculator provides general guidelines. Always consult with a healthcare professional for personalized advice.

async function onConfigChange(config) { const mainTitle = document.getElementById('main-title'); const subtitle = document.getElementById('subtitle'); const calculateBtn = document.getElementById('calculate-btn'); const disclaimerText = document.getElementById('disclaimer-text');

const customFont = config.font_family || defaultConfig.font_family; const baseFontStack = 'system-ui, -apple-system, sans-serif'; const baseSize = config.font_size || defaultConfig.font_size;

document.body.style.fontFamily = `${customFont}, ${baseFontStack}`;

mainTitle.textContent = config.main_title || defaultConfig.main_title; mainTitle.style.color = config.primary_color || defaultConfig.primary_color; mainTitle.style.fontSize = `${baseSize * 3.125}px`;

subtitle.textContent = config.subtitle || defaultConfig.subtitle; subtitle.style.color = config.secondary_text_color || defaultConfig.secondary_text_color; subtitle.style.fontSize = `${baseSize * 1.25}px`;

calculateBtn.textContent = config.button_text || defaultConfig.button_text; calculateBtn.style.backgroundColor = config.primary_color || defaultConfig.primary_color; calculateBtn.style.fontSize = `${baseSize * 1.25}px`;

disclaimerText.textContent = config.disclaimer_text || defaultConfig.disclaimer_text; disclaimerText.style.fontSize = `${baseSize * 0.875}px`;

const gradientBg = document.querySelector('.gradient-bg'); gradientBg.style.background = `linear-gradient(135deg, ${config.primary_color || defaultConfig.primary_color} 0%, ${config.secondary_color || defaultConfig.secondary_color} 100%)`;

const card = document.querySelector('.rounded-3xl'); card.style.backgroundColor = config.background_color || defaultConfig.background_color;

const labels = document.querySelectorAll('label'); labels.forEach(label => { label.style.color = config.text_color || defaultConfig.text_color; label.style.fontSize = `${baseSize * 1.125}px`; });

const resultTitle = document.querySelector('#results h2'); if (resultTitle) { resultTitle.style.color = config.text_color || defaultConfig.text_color; resultTitle.style.fontSize = `${baseSize * 1.5}px`; }

const weightRange = document.getElementById('weight-range'); if (weightRange) { weightRange.style.color = config.primary_color || defaultConfig.primary_color; weightRange.style.fontSize = `${baseSize * 1.25}px`; } }

function mapToCapabilities(config) { return { recolorables: [ { get: () => config.primary_color || defaultConfig.primary_color, set: (value) => { config.primary_color = value; window.elementSdk.setConfig({ primary_color: value }); } }, { get: () => config.secondary_color || defaultConfig.secondary_color, set: (value) => { config.secondary_color = value; window.elementSdk.setConfig({ secondary_color: value }); } }, { get: () => config.background_color || defaultConfig.background_color, set: (value) => { config.background_color = value; window.elementSdk.setConfig({ background_color: value }); } }, { get: () => config.text_color || defaultConfig.text_color, set: (value) => { config.text_color = value; window.elementSdk.setConfig({ text_color: value }); } }, { get: () => config.secondary_text_color || defaultConfig.secondary_text_color, set: (value) => { config.secondary_text_color = value; window.elementSdk.setConfig({ secondary_text_color: value }); } } ], borderables: [], fontEditable: { get: () => config.font_family || defaultConfig.font_family, set: (value) => { config.font_family = value; window.elementSdk.setConfig({ font_family: value }); } }, fontSizeable: { get: () => config.font_size || defaultConfig.font_size, set: (value) => { config.font_size = value; window.elementSdk.setConfig({ font_size: value }); } } }; }

function mapToEditPanelValues(config) { return new Map([ ["main_title", config.main_title || defaultConfig.main_title], ["subtitle", config.subtitle || defaultConfig.subtitle], ["button_text", config.button_text || defaultConfig.button_text], ["disclaimer_text", config.disclaimer_text || defaultConfig.disclaimer_text] ]); }

if (window.elementSdk) { window.elementSdk.init({ defaultConfig, onConfigChange, mapToCapabilities, mapToEditPanelValues }); }

document.getElementById('weightForm').addEventListener('submit', function(e) { e.preventDefault();

const age = parseInt(document.getElementById('age').value); const height = parseFloat(document.getElementById('height').value); const gender = document.getElementById('gender').value;

const heightInMeters = height / 100;

let minBMI, maxBMI; if (age < 18) { minBMI = 18.5; maxBMI = 24.9; } else if (age >= 18 && age < 65) { minBMI = 18.5; maxBMI = 24.9; } else { minBMI = 23; maxBMI = 27; } const minWeight = (minBMI * heightInMeters * heightInMeters).toFixed(1); const maxWeight = (maxBMI * heightInMeters * heightInMeters).toFixed(1); document.getElementById('weight-range').textContent = `${minWeight} - ${maxWeight} kg`; document.getElementById('bmi-range').textContent = `BMI ${minBMI} - ${maxBMI}`; let ageNote = ''; if (age < 18) { ageNote = 'Note: For children and adolescents, weight ranges can vary significantly with growth. Please consult a pediatrician.'; } else if (age >= 65) { ageNote = 'Note: For older adults, slightly higher BMI ranges are considered healthy to maintain muscle mass and bone density.'; } else { ageNote = 'This range is based on standard healthy BMI guidelines for adults.'; }

document.getElementById('age-note').textContent = ageNote;

const resultsDiv = document.getElementById('results'); resultsDiv.classList.remove('hidden'); resultsDiv.classList.add('result-appear');

resultsDiv.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); });