Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //requires height and weight to be passed
- function calculateBmi() {
- let weight = document.getElementById("weight").value;
- let height = document.getElementById("height").value;
- console.log("weight"+weight+" height"+height);
- if(weight > 0 && height > 0){
- var finalBmi = weight/(height/100*height/100)
- document.bmiForm.bmi.value = finalBmi
- if(finalBmi < 18.5){
- document.bmiForm.meaning.value = "That you are too thin."
- }
- if(finalBmi > 18.5 && finalBmi < 25){
- document.bmiForm.meaning.value = "That you are healthy."
- }
- if(finalBmi > 25){
- document.bmiForm.meaning.value = "That you are overweight."
- }
- }
- else{
- alert("Please Fill in everything correctly")
- }
- }
- //requires height and weight to be passed
- function calculateBmi() {
- let weight = document.getElementById("weight").value;
- let height = document.getElementById("height").value;
- console.log("weight"+weight+" height"+height);
- if(weight > 0 && height > 0){
- var finalBmi = weight/(height/100*height/100)
- document.bmiForm.bmi.value = finalBmi
- if(finalBmi < 18.5){
- document.bmiForm.meaning.value = "That you are too thin."
- }
- if(finalBmi > 18.5 && finalBmi < 25){
- document.bmiForm.meaning.value = "That you are healthy."
- }
- if(finalBmi > 25){
- document.bmiForm.meaning.value = "That you are overweight."
- }
- }
- else{
- alert("Please Fill in everything correctly")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement