Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. //requires height and weight to be passed
  2. function calculateBmi() {
  3. let weight = document.getElementById("weight").value;
  4. let height = document.getElementById("height").value;
  5.  
  6. console.log("weight"+weight+" height"+height);
  7.  
  8. if(weight > 0 && height > 0){
  9. var finalBmi = weight/(height/100*height/100)
  10. document.bmiForm.bmi.value = finalBmi
  11. if(finalBmi < 18.5){
  12. document.bmiForm.meaning.value = "That you are too thin."
  13. }
  14. if(finalBmi > 18.5 && finalBmi < 25){
  15. document.bmiForm.meaning.value = "That you are healthy."
  16. }
  17. if(finalBmi > 25){
  18. document.bmiForm.meaning.value = "That you are overweight."
  19. }
  20. }
  21. else{
  22. alert("Please Fill in everything correctly")
  23. }
  24. }
  25.  
  26.  
  27.  
  28.  
  29.  
  30. //requires height and weight to be passed
  31. function calculateBmi() {
  32. let weight = document.getElementById("weight").value;
  33. let height = document.getElementById("height").value;
  34.  
  35. console.log("weight"+weight+" height"+height);
  36.  
  37. if(weight > 0 && height > 0){
  38. var finalBmi = weight/(height/100*height/100)
  39. document.bmiForm.bmi.value = finalBmi
  40. if(finalBmi < 18.5){
  41. document.bmiForm.meaning.value = "That you are too thin."
  42. }
  43. if(finalBmi > 18.5 && finalBmi < 25){
  44. document.bmiForm.meaning.value = "That you are healthy."
  45. }
  46. if(finalBmi > 25){
  47. document.bmiForm.meaning.value = "That you are overweight."
  48. }
  49. }
  50. else{
  51. alert("Please Fill in everything correctly")
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement