Length Converter

This weight converter can convert seven 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 seven units.  For example, you select "Meter" and entered 12 in the box beside the pull-down menu, then you can see what is 26 meter in other units.

Unit Number
Centimeter: 
Meter: 
Kilometer: 
Inch: 
Foot: 
Yard: 
Mile: 

 
Cut and paste the source code of the above script here (Read  How to Cut N Paste for help)
<!-----------------Cut---------------->
<HTML>
<HEAD>
<TITLE>Length 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 centimeter, and then it converts the unit fram centimeterto
other units.*/


function nofocus()
{
document.convert.InUnit.focus()
}


var cmValue = 1
var mValue = 100
var kmValue = 100000
var inValue = 2.54000843476
var ftValue = 30.4801012183
var ydValue = 91.440275784
var miValue = 1609.34708789


function toCM()
{
var i = document.convert.unit.selectedIndex
var thisUnit = document.convert.unit.options[i].value
if (thisUnit == "CM")
 {
document.convert.cm.value = document.convert.InUnit.value
 }
else if(thisUnit == "M")
 {
document.convert.cm.value = document.convert.InUnit.value * mValue
 }
else if(thisUnit == "KM" )
 {
document.convert.cm.value = document.convert.InUnit.value * kmValue
 }
else if(thisUnit == "IN" )
 {
document.convert.cm.value = document.convert.InUnit.value * inValue
 }
else if(thisUnit == "FT" )
 {
document.convert.cm.value = document.convert.InUnit.value * ftValue
 }
else if(thisUnit == "YD" )
 {
document.convert.cm.value = document.convert.InUnit.value * ydValue
 }
else if(thisUnit == "MI" )
 {
document.convert.cm.value = document.convert.InUnit.value * miValue
 }


toAll()
}


function toAll()
{
var m = document.convert.cm.value
document.convert.m.value = m / mValue
document.convert.km.value = m / kmValue
document.convert.inch.value = m / inValue
document.convert.ft.value = m / ftValue
document.convert.yd.value = m / ydValue
document.convert.mi.value = m / miValue
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="convert">
<TABLE BORDER=1>
<TR><TH>Unit</TH><TH>Number</TH></TR>
 <TR>
 
  <TD>
<SELECT NAME="unit">
<OPTION VALUE = "CM">Centimeter
<OPTION VALUE = "M">Meter
<OPTION VALUE = "KM">Kilometer
<OPTION VALUE = "IN">Inch
<OPTION VALUE = "FT">Foot
<OPTION VALUE = "YD">Yard
<OPTION VALUE = "MI">Mile
</SELECT>
  </TD>
  <TD>
<INPUT TYPE="text" NAME="InUnit" SIZE="20" MAXLENGTH="20" VALUE="0">
  </TD>
 </TR>
 <TR>
  <TD>
Centimeter:   </TD>
  <TD>
<INPUT TYPE="text" NAME="cm" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
  </TD>
 </TR>
 <TR>
  <TD>
Meter:
   </TD>


  <TD>
<INPUT TYPE="text" NAME="m" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
  </TD>
 </TR>
 <TR>
  <TD>
Kilometer:   </TD>
  <TD>
<INPUT TYPE="text" NAME="km" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
  </TD>
 </TR>
 <TR>
  <TD>
Inch:   </TD>
  <TD>
<INPUT TYPE="text" NAME="inch" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
  </TD>
 </TR>
 <TR>
  <TD>
Foot:   </TD>
  <TD>
<INPUT TYPE="text" NAME="ft" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">  </TD>
 </TR>
 <TR>
  <TD>
Yard:   </TD>
  <TD>
<INPUT TYPE="text" NAME="yd" SIZE="20" MAXLENGTH="20" VALUE="0" onFocus="nofocus()">
  </TD>
 </TR>
 <TR>
  <TD>
Mile:   </TD>
  <TD>
<INPUT TYPE="text" NAME="mi" 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