How TO - Weight Converter

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





googletag.cmd.push(function() googletag.display('div-gpt-ad-1422003450156-2'); );



How TO - Weight Converter



❮ Previous
Next ❯


Learn how to create a weight converter with HTML and JavaScript.




Weight Converter





Type a value in any of the fields to convert between weight measurements:

























Create a Weight Converter


Create an input element that can convert a value from one weight measurement to another.


Step 1) Add HTML:


Example - Pounds to Kilogram



<p>
  <label>Pounds</label>
  <input id="inputPounds" type="number" placeholder="Pounds"
  oninput="weightConverter(this.value)" onchange="weightConverter(this.value)">
</p>
<p>Grams: <span id="outputGrams"></span></p>




Step 2) Add JavaScript:


Example - Pounds to Kilogram



/* When the input field receives input, convert the value from pounds to kilograms */

function weightConverter(valNum)
  document.getElementById("outputGrams").innerHTML = valNum / 0.0022046;

Try it Yourself »








googletag.cmd.push(function() googletag.display('div-gpt-ad-1493883843099-0'); );





Convert from Pounds to other Measurements


The table below shows how to convert from Pounds to other weight
measurements:


















Description Formula Example
Convert from Pounds to Kilograms kg=lb/2.2046 Try it
Convert from Pounds to Ounces oz=lb*16 Try it
Convert from Pounds to Grams g=lb/0.0022046 Try it
Convert from Pounds to Stones st=lb*0.071429 Try it

Convert from Kilograms to other Measurements


The table below shows how to convert from Kilograms to other weight
measurements:


















Description Formula Example
Convert from Kilograms to Pounds lb=kg*2.2046 Try it
Convert from Kilograms to Ounces oz=kg*35.274 Try it
Convert from Kilograms to Grams g=kg*1000 Try it
Convert from Kilograms to Stones st=kg*0.1574 Try it

Convert from Ounces to other Measurements


The table below shows how to convert from Ounces to other weight
measurements:


















Description Formula Example
Convert from Ounces to Pounds lb=oz*0.0625 Try it
Convert from Ounces to Kilograms kg=oz/35.274 Try it
Convert from Ounces to Grams g=oz/0.035274 Try it
Convert from Ounces to Stones st=oz*0.0044643 Try it

Convert from Grams to other Measurements


The table below shows how to convert from Grams to other weight
measurements:


















Description Formula Example
Convert from Grams to Pounds lb=g*0.0022046 Try it
Convert from Grams to Kilograms kg=g/1000 Try it
Convert from Grams to Ounces oz=g*0.035274 Try it
Convert from Grams to Stones st=g*0.00015747 Try it

Convert from Stones to other Measurements


The table below shows how to convert from Stones to other weight
measurements:


















Description Formula Example
Convert from Stones to Pounds lb=st*14 Try it
Convert from Stones to Kilograms kg=st/0.15747 Try it
Convert from Stones to Ounces oz=st*224 Try it
Convert from Stones to Grams g=st/0.00015747 Try it



function weightConverter(source,valNum)
valNum = parseFloat(valNum);
var inputPounds = document.getElementById("inputPounds");
var inputKilograms = document.getElementById("inputKilograms");
var inputOunces = document.getElementById("inputOunces");
var inputGrams = document.getElementById("inputGrams");
var inputStones = document.getElementById("inputStones");
if (source=="inputPounds")
inputKilograms.value=(valNum/2.2046).toFixed(2);
inputOunces.value=(valNum*16).toFixed(2);
inputGrams.value=(valNum/0.0022046).toFixed();
inputStones.value=(valNum*0.071429).toFixed(3);

if (source=="inputKilograms")
inputPounds.value=(valNum*2.2046).toFixed(2);
inputOunces.value=(valNum*35.274).toFixed(2);
inputGrams.value=(valNum*1000).toFixed();
inputStones.value=(valNum*0.1574).toFixed(3);

if (source=="inputOunces")
inputPounds.value=(valNum*0.062500).toFixed(4);
inputKilograms.value=(valNum/35.274).toFixed(4);
inputGrams.value=(valNum/0.035274).toFixed(1);
inputStones.value=(valNum*0.0044643).toFixed(4);

if (source=="inputGrams")
inputPounds.value=(valNum*0.0022046).toFixed(4);
inputKilograms.value=(valNum/1000).toFixed(4);
inputOunces.value=(valNum*0.035274).toFixed(3);
inputStones.value=(valNum*0.00015747).toFixed(5);

if (source=="inputStones")
inputPounds.value=(valNum*14).toFixed(1);
inputKilograms.value=(valNum/0.15747).toFixed(1);
inputOunces.value=(valNum*224).toFixed();
inputGrams.value=(valNum/0.00015747).toFixed();





❮ Previous
Next ❯

Popular posts from this blog

WWE Night of Champions

Poznań

Kaliningrad