»
AnglaisFrançaisVietnamien

Imprimer - Length Converter - JavaScriptBank.com

Version complète: jsB@nk » Calcul » Équivalent » Length Converter
URL: https://www.javascriptbank.com/length-converter.html

Length Converter © JavaScriptBank.comConvertir des unités de l'un à l'autre. Il vous suffit de choisir l'unité que vous voulez utiliser, tapez la valeur dans le champ à côté de lui, et cliquez sur 'Convert' button.

Version complète: jsB@nk » Calcul » Équivalent » Length Converter
URL: https://www.javascriptbank.com/length-converter.html



JavaScript
<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 centimeter, and then it converts the unit fram centimetertoother units.*/function nofocus(){   document.convert.InUnit.focus()}var cmValue = 1var mValue = 100var kmValue = 100000var inValue = 2.54000843476var ftValue = 30.4801012183var ydValue = 91.440275784var miValue = 160934.708789function 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.valuedocument.convert.m.value = m / mValuedocument.convert.km.value = m / kmValuedocument.convert.inch.value = m / inValuedocument.convert.ft.value = m / ftValuedocument.convert.yd.value = m / ydValuedocument.convert.mi.value = m / miValue}//--></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM name=convert><TABLE border=1>  <TBODY>  <TR>    <TH>Unit</TH>    <TH>Number</TH></TR>  <TR>    <TD><SELECT name=unit> <OPTION value=CM selected>Centimetre<OPTION         value=M>Metre<OPTION value=KM>Kilometre<OPTION value=IN>Inch<OPTION         value=FT>Foot<OPTION value=YD>Yard<OPTION     value=MI>Mile</OPTION></SELECT></TD>    <TD><INPUT maxLength=20 value=0 name=InUnit></TD></TR>  <TR>    <TD>Centimetre: </TD>    <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=cm></TD></TR>  <TR>    <TD>Metre:</TD>    <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=m></TD></TR>  <TR>    <TD>Kilometre: </TD>    <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=km></TD></TR>  <TR>    <TD>Inch: </TD>    <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=inch></TD></TR>  <TR>    <TD>Foot: </TD>    <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=ft></TD></TR>  <TR>    <TD>Yard: </TD>    <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=yd></TD></TR>  <TR>    <TD>Mile: </TD>    <TD><INPUT onfocus=nofocus() maxLength=20 value=0 name=mi></TD></TR>  <TR>    <TD align=middle><INPUT type=reset value="Start Over"></TD>    <TD   align=middle><INPUT onclick=toCM() type=button value=Convert></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-->