topical media & game development

talk show tell print

lib-js-math-calculator-weight-watch.htm / htm



  <head>
  <script>
  /* This script and many more are available free online at
  The JavaScript Source!! http://javascript.internet.com
  Created by: Webmilhouse | http://www.webmilhouse.com/ */
  function calculate() {
           var doc = document.pointCalc;
           var points = 0;
           var fiber = doc.fiber.value;
      if(fiber > 4) fiber = 4;
           var fat = doc.fat.value;
           var calories = doc.calories.value;
  
           points = (calories / 50) + (fat / 12) - (fiber / 5);
           doc.result.value = Math.round(points);
  }
  </script>
  
  <!--
  <script type="text/javascript" src="wwCalc.js"></script>
  -->
  <body>
  
  <form name="pointCalc">
  <table>
  <tr>
  <td width="100">Calories:</td>
  <td><input type="text" name="calories" size="5" style="text-align: right;"></td>
  </tr><tr>
  <td>Fat:</td>
  <td><input type="text" name="fat" size="5" style="text-align: right;"></td>
  </tr><tr>
  <td>Fiber:</td>
  <td><input type="text" name="fiber" size="5" style="text-align: right;"></td>
  </td>
  </tr><tr>
  <td> </td>
  <td colspan="2"><input type="button" value="Calculate" onClick="calculate();"></td>
  </tr><tr>
  <td><strong>Points:</strong></td>
  <td><input type="text" name="result" size="5" readonly="readonly" style="border: none; text-align: right; font-weight: bold;"></td>
  </tr>
  </table>
  </form>
  
  </body>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.