Skip to content

BMI Calculator #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,4 +609,11 @@ const entries = [
author: "Rupesh Soni",
github: "rsoni124"
},
{
title: "BMI Calculator",
filename: "BMI-Calculator.html",
description: "Calculates Body Mass Index based on your weigth and heigth",
author: "Alexis Ortiz",
github: "AlexiusOL"
},
];
99 changes: 99 additions & 0 deletions entries/BMI-Calculator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!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>
</head>
<body>
<style type="text/css">
html {
background-color: rgb(29, 29, 30);
}
body {
background-color: rgb(40, 78, 70);
align-items: center;
border: 2px aliceblue solid;
border-radius: 5px;
padding: 10px 15px;
margin: 10px auto;
width: 700px;
}
h1 {
text-align: center;
color: azure;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', sans-serif;
}
p {
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', sans-serif;
color: aquamarine;
}
.center-input {
text-align: center;
}
.center-input button {
margin-top: 20px;
background-color: #04AA6D;
border: none;
color: white;
padding: 12px 25px;
text-decoration: none;
display: inline-block;
font-size: 13px;
}



</style>

<h1>BMI Calculator</h1>
<div class="center-input">
<input type="number" placeholder="Weigth in kilograms" id="peso" title="Made by AlexiusOL">
<input type="number" placeholder="Heigth in meters" id="altura" title="One Html Page Challenge"> <br>
<button onclick="calcular()">Calculate</button>

<p>BMI: <span id="res"></span> </p>
<p>Your BMI is: <span id="status"></span></p>

</div>




<script type="text/javascript">

function calcular() {
var peso = parseFloat(document.getElementById("peso").value);
var altura = parseFloat(document.getElementById("altura").value);
var res = document.getElementById("res");
var status = document.getElementById("status");

if(peso > 0 && altura > 0) {
var imc = (peso / (altura * altura)).toFixed(2);
res.innerHTML = imc;

if(imc <= 18.4) {
status.innerHTML = "Low";
status.style.color = 'white';
}
else if(imc >= 18.4 && imc <= 24.9) {
status.innerHTML = "Normal";
status.style.color = 'aquamarine';
}
else if(imc >= 25 && imc <= 29.9) {
status.innerHTML = "Overweigth";
status.style.color = '#f0651a';
}
else {
status.innerHTML = "Obese";
status.style.color = '#eb1818'
}
}
else {
res.innerHTML = "Nothing";
status.innerHTML = "Nothing";
}
}
</script>
</body>
</html>