Introduction | Demonstration Calculator | Source Code
How This Calculator Works
Find out how much you’d be worth if you were worth your weight in SPAM®, with this fun calculator.
Just enter your body weight, actual price of SPAM, and press the “calculate” button to find out how much your weight is worth in SPAM. By default, the price of SPAM is $0.00684 per gram ($13.99 for six 12-ounce cans).
Introduction | Demonstration Calculator | Source Code
Demonstration Calculator
Introduction | Demonstration Calculator | Source Code
Your Weight in SPAM® Calculator Source Code
This calculator is licensed to you under Creative Commons Attribution 3.0. If you would like to use the source code on your site or create a derivative work from it, you must include the following HTML on the page where the calculator appears. We’re giving you this code for free with a legal license to use it. All you have to do is credit us in the manner we specify.
Required Credit HTML
INSTALLATION
Just cut and paste the Javascript code and HTML form below into your page. If you want to customize the appearance of the form, feel free. Just make sure the input name and form id/name values are not changed.
<script type="text/javascript">
function calcWeightSPAM(){
// GET VALUES FROM FORM, SET VALUE TO ONE IF THE VALUE IN THE FORM IS NOT A NUMBER
var weight = (isNaN(document.wcbubba.weight.value)) ? 1 : document.wcbubba.weight.value;
var price = (isNaN(document.wcbubba.price.value)) ? 1 : document.wcbubba.price.value;
var wis = document.wcbubba.wis.value;
var wospam = document.wcbubba.wospam.value;
if(wis == "pound"){weight = weight / 2.205;}
if(wospam == "ounce"){price = price * 28.3495;}
// DO CALCULATION
var result = parseInt((weight * 1000 * price) * 100) / 100;
var expout = 'Your weight in SPAM® is worth: $' + result;
document.getElementById('totals').innerHTML = expout;
}
</script>
<form name="wcbubba" action="javascript:void();">
Your Weight:<br>
<input name="weight" size="5" type="text" />
<select name="wis" size="1">
<option value="kilogram" selected="selected">kg</option>
<option value="pound">pounds</option>
</select><br><br>
Price of SPAM (in dollars):<br>
<input name="price" size="5" type="text" value="0.00684" /> per
<select name="wospam" size="1">
<option value="gram" selected="selected">gram</option>
<option value="ounce">ounce</option>
</select>
<input type="submit" value="calculate" onclick="calcWeightSPAM()"></form><br>
<div id="totals" style="padding-top:1em;padding-bottom:2em"></div>