topical media & game development

talk show tell print

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

  /* This script and many more are available free online at
  The JavaScript Source!!
  Created by: Webmilhouse | */
  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 type="text/javascript" src="wwCalc.js"></script>
  <form name="pointCalc">
  <td width="100">Calories:</td>
  <td><input type="text" name="calories" size="5" style="text-align: right;"></td>
  <td><input type="text" name="fat" size="5" style="text-align: right;"></td>
  <td><input type="text" name="fiber" size="5" style="text-align: right;"></td>
  <td> </td>
  <td colspan="2"><input type="button" value="Calculate" onClick="calculate();"></td>
  <td><input type="text" name="result" size="5" readonly="readonly" style="border: none; text-align: right; font-weight: bold;"></td>

(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.