Full version: jsB@nk » Calculation » Equivalent » Weight Converter
URL: https://www.javascriptbank.com/weight-converter.html
This JavaScript creates a weight converter that can convert five different units at one time. To use it, choose your unit at the first line and enter the a number in the box beside it, then click the convert button. It automatically converts your choice to all five units.
Full version: jsB@nk » Calculation » Equivalent » Weight Converter
URL: https://www.javascriptbank.com/weight-converter.html
<SCRIPT language=JavaScript type=text/javascript><!--// Script Editor: Howard Chen// Browser Compatible for the script: IE 3.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 numberinto the smallest unit in the converter, in this case it willbe gram, and then it converts the unit fram gram to other units.*/function nofocus(){document.convert.InUnit.focus()}var gValue = 1var kgValue = 1000var ounceValue = 28.3495var lbValue = 453.592var tValue = 907184function toCM(){var i = document.convert.unit.selectedIndexvar thisUnit = document.convert.unit.options[i].valueif (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.valuedocument.convert.kg.value = m / kgValuedocument.convert.ounce.value = m / ounceValuedocument.convert.lb.value = m / lbValuedocument.convert.t.value = m / tValue}//--></SCRIPT><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<FORM name=convert><TABLE border=1> <TBODY> <TR> <TH>Unit</TH> <TH>Number</TH></TR> <TR> <TD><SELECT name=unit> <OPTION value=G selected>Gram<OPTION value=KG>Kilogram<OPTION value=OUNCE>Ounce<OPTION value=LB>Pound<OPTION value=T>U.S. Ton</OPTION></SELECT> </TD> <TD><INPUT maxLength=20 value=0 name=InUnit size="20"> </TD></TR> <TR> <TD>Gram: </TD> <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=g size="20"> </TD></TR> <TR> <TD>Kilogram: </TD> <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=kg size="20"> </TD></TR> <TR> <TD>Ounce: </TD> <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=ounce size="20"> </TD></TR> <TR> <TD>Pound: </TD> <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=lb size="20"> </TD></TR> <TR> <TD>U.S. Ton: </TD> <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=t size="20"></TD></TR> <TR> <TD><INPUT type=reset value="Start Over" width="100"> </TD> <TD><INPUT onclick=toCM() type=button value=Convert width="150"> </TD></TR></TBODY></TABLE></FORM><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->