General
Are you designing a diet Web site? Are you using the Weight Watchers Points plan to lose weight? If so, this little calculator might just come in handy. A simple but quick method to figure WW points.
Calories: | |
Fat: | |
Fiber: | |
Points: |
Notes
- Created by: Webmilhouse
- Web Site: http://www.webmilhouse.com/
Source Code
Paste this source code into the designated areas.
External file
Paste this code into an external JavaScript file named: wwCalc.js
/* This script and many more are available free online at
The JavaScript Source!! http://javascriptsource.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);
}
Head
Paste this code into the HEAD
section of your HTML document.
<script type=”text/javascript” src=”wwCalc.js”></script>
Body
Paste this code into the BODY
section of your HTML document.
<form name="pointCalc" id="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>
</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>