Advertisement
zerosensitivity

Home work

Nov 18th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1.  
  2.  
  3. // the hhtml
  4. <html>
  5. <head>
  6. <script src="js/script.js" type="text/javascript"> </script>
  7. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
  8. <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  9. <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
  10. </head>
  11. <body>
  12.  
  13. <form name="bmiForm">
  14. Your Weight(kg): <input type="text" name="weight" id="weight" size="10"><br />
  15. Your Height(cm): <input type="text" name="height" id="height" size="10"><br />
  16. <input type="button" value="Calculate BMI" onClick="calculateBmi()"><br />
  17. Your BMI: <input type="text" id="bmi" size="10"><br />
  18. This Means: <input type="text" id="meaning" size="25"><br />
  19. <input type="reset" value="Reset" />
  20. </form>
  21.  
  22.  
  23.  
  24. </body>
  25. </html>
  26.  
  27.  
  28.  
  29. /the java script change file follder to js
  30.  
  31. //requires height and weight to be passed
  32. function calculateBmi() {
  33.  
  34. //let weight = document.getElementById("weight").value;
  35. let weight = $("#weight").val();
  36. let height = $("#height").val();
  37.  
  38. //let height = document.getElementById("height").value;
  39.  
  40. console.log("weight"+weight+" height"+height);
  41.  
  42. if(weight > 0 && height > 0){
  43. var finalBmi = weight/(height/100*height/100)
  44. document.bmiForm.bmi.value = finalBmi
  45. if(finalBmi < 18.5){
  46. document.bmiForm.meaning.value = "That you are too thin."
  47. }
  48. if(finalBmi > 18.5 && finalBmi < 25){
  49. document.bmiForm.meaning.value = "That you are healthy."
  50. }
  51. if(finalBmi > 25){
  52. document.bmiForm.meaning.value = "That you are overweight."
  53. }
  54. }
  55. else{
  56. alert("Please Fill in everything correctly")
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement