Weight Converter

This weight converter can convert five different units at one time, choose your unit at the first line and enter the a number in the box beside it, then it automatically converts it to all five units.  For example, you select "Kilogram" and entered 26 in the box beside the pull-down menu, then you can see what is 26 kilogram in other units.  The solution should be: 26 Gram, 26 Kilogram, 917.1237587964515 Ounce... etc.
 

Unit Number
Gram: 
Kilogram: 
Ounce: 
Pound: 
U.S. Ton: 

 

Cut and paste the source code of the above script here (Read  How to Cut N Paste for help)

<!-----------------Cut---------------->
<HTML>
<HEAD>
<TITLE>Weight Converter</TITLE>
<SCRIPT>
<!--
//    Script Editor:   Howard Chen
//    Browser Compatible for the script: IE 2.0 or Higher
//                                       Netscape 2.0 or Higher
//    This script is free as long as you keep its credits
/*The way this works is the converter converts the number
into the smallest unit in the converter, in this case it will
be gram, and then it converts the unit fram gram to other units.*/
function nofocus()
{
document.convert.InUnit.focus()
}
var gValue = 1
var kgValue = 1000
var ounceValue = 28.3495
var lbValue = 453.592
var tValue = 907184
function toCM()
{
var i = document.convert.unit.selectedIndex
var thisUnit = document.convert.unit.options[i].value
if (thisUnit == "G")
        {
document.convert.g.value = document.convert.InUnit.value
        }
else if(thisUnit == "KG")
        {
document.convert.g.value = document.convert.InUnit.value * kgValue
        }
else if(thisUnit == "OUNCE" )
        {
document.convert.g.value = document.convert.InUnit.value * ounceValue
        }
else if(thisUnit == "LB" )
        {
document.convert.g.value = document.convert.InUnit.value * lbValue
        }
else if(thisUnit == "T" )
        {
document.convert.g.value = document.convert.InUnit.value * tValue
        }
toAll()
}
function toAll()
{
var m = document.convert.g.value
document.convert.kg.value = m / kgValue
document.convert.ounce.value = m / ounceValue
document.convert.lb.value = m / lbValue
document.convert.t.value = m / tValue
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="convert">
<TABLE BORDER=1>
<TR><TH>Unit</TH><TH>Number</TH></TR>
        <TR>
                <TD>
<SELECT NAME="unit">
<OPTION VALUE = "G">Gram
<OPTION VALUE = "KG">Kilogram
<OPTION VALUE = "OUNCE">Ounce
<OPTION VALUE = "LB">Pound
<OPTION VALUE = "T">U.S. Ton
</SELECT>
                </TD>
                <TD>
<INPUT TYPE="text" NAME="InUnit" SIZE="20" MAXLENGTH="20" VALUE="0">
                </TD>
        </TR>
        <TR>
                <TD>
Gram:                   </TD>
                <TD>
<INPUT TYPE="text" NAME="g" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
                </TD>
        </TR>
        <TR>
                <TD>
Kilogram:
                </TD>
                <TD>
<INPUT TYPE="text" NAME="kg" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
                </TD>
        </TR>
        <TR>
                <TD>
Ounce:          </TD>
                <TD>
<INPUT TYPE="text" NAME="ounce" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
                </TD>
        </TR>
        <TR>
                <TD>
Pound:          </TD>
                <TD>
<INPUT TYPE="text" NAME="lb" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
                </TD>
        </TR>
        <TR>
                <TD>
U.S. Ton:               </TD>
                <TD>
<INPUT TYPE="text" NAME="t" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">             </TD>
        </TR>
        <TR>
                <TD>
<INPUT TYPE="Reset" VALUE="Start Over" WIDTH=100>
                </TD>
                <TD>
<INPUT TYPE="button" VALUE="Convert" onClick="toCM()" WIDTH=150>
                </TD>
        </TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<!------------------End------------------->
IMPORTANT: The scripts provided in this page are free as long as you keep the credits in the code.  E-mail me or use Script Rebuild Service for additional help about Cut N Paste or to ask for a script that is just for you.

Post Your Script Home