home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Archived / Internet / jvscript116beta / JvScript / !JvScript / Resources / Scripts / XCalcs / 2 < prev    next >
Encoding:
Text File  |  1999-09-15  |  2.5 KB  |  95 lines

  1. #newformat
  2. _title:Body Mass Index
  3. _author:Marat Rikelman
  4. _source:http://javascript.internet.com
  5. _description:It uses a formula to figure out your Body Mass Index and thus whether you are under or overweight.
  6.  
  7. _insert-in:inhead
  8. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  9.  
  10. <!-- Original:  Marat Rikelman (rikelman@bellsouth.net) -->
  11.  
  12. <!-- This script and many more are available free online at -->
  13. <!-- The JavaScript Source!! http://javascript.internet.com -->
  14.  
  15. <!-- Begin
  16. function mod(div,base) {
  17. return Math.round(div - (Math.floor(div/base)*base));
  18. }
  19. function calcBmi() {
  20. var w = document.bmi.weight.value * 1;
  21. var HeightFeetInt = document.bmi.htf.value * 1;
  22. var HeightInchesInt = document.bmi.hti.value * 1;
  23. HeightFeetConvert = HeightFeetInt * 12;
  24. h = HeightFeetConvert + HeightInchesInt;
  25. displaybmi = (Math.round((w * 703) / (h * h)));
  26. var rvalue = true;
  27. if ( (w <= 35) || (w >= 500)  || (h <= 48) || (h >= 120) ) {
  28. alert ("Invalid data.  Please check and re-enter!");
  29. rvalue = false;
  30. }
  31. if (rvalue) {
  32. if (HeightInchesInt > 11) {
  33. reminderinches = mod(HeightInchesInt,12);
  34. document.bmi.hti.value = reminderinches;
  35. document.bmi.htf.value = HeightFeetInt + 
  36. ((HeightInchesInt - reminderinches)/12);
  37. document.bmi.answer.value = displaybmi;
  38. }
  39. if (displaybmi <19) 
  40. document.bmi.comment.value = "Underweight";
  41. if (displaybmi >=19 && displaybmi <=25) 
  42. document.bmi.comment.value = "Desirable";
  43. if (displaybmi >=26 && displaybmi <=29) 
  44. document.bmi.comment.value = "prone to health risks";
  45. if (displaybmi >=30 && displaybmi <=40) 
  46. document.bmi.comment.value = "Obese";
  47. if (displaybmi >40) 
  48. document.bmi.comment.value = "Extremely obese";
  49. document.bmi.answer.value = displaybmi; }
  50. return rvalue;
  51. }
  52. //  End -->
  53.  
  54. </SCRIPT>
  55. _end-insert:
  56.  
  57. _insert-in:inbody
  58. <form name=bmi>
  59. <center>
  60. <table width=200 border=0>
  61. <tr>
  62. <td align=center><B>Weight:</B>
  63. <input type=text name=weight SIZE=3 maxlength=3> lbs.</td>
  64. </tr>
  65. <tr>
  66. <td align=center><B>Height:</B>
  67. <input type=text name=htf size=1 maxlength=1> Ft.         
  68. <input type=text name=hti size=2 maxlength=2> In.
  69. </td>
  70. </tr>
  71. <tr>
  72. <td align=center>
  73. <input type=button value="Calculate BMI" onclick="calcBmi()">
  74.  
  75. <hr></td>
  76. </tr>
  77. <tr>
  78. <td><B>Body Mass Index</B>
  79. <input type=text name=answer size=3>
  80. </td>
  81. </tr>
  82. <tr>
  83. <td>
  84. According to the Panel on Energy, Obesity, and 
  85. Body Weight Standards published by American 
  86. Journal of Clinical Nutrition, your category is:<br>
  87. <input type=text name=comment size=25>
  88. </td>
  89. </tr>
  90. </table>
  91. </center>
  92. </form>
  93. _end-insert:
  94.  
  95.