Metachecker.net
|
FontsMadeEasy.com
|
RankChecker.net
Learn Java Script Today
|
Over 5000 Free Fonts
|
Tutorials
|
Javascript Forum
|
Other Javascript Resources
|
Cheat Sheet
JavaScript Basics
Inserting Javascript
Complete Tutorial
Advance DHTML Tutorial
Script archive
Advanced Tutorials
Alert Scripts
Animation
Audio
Background Effects
Banner Ads
Browser Window
Buttons
Button Forms
Calculcators
Calendars
Clocks & Dates
Cookies
Cursor Effects
DHMTL Games
DHTML Miscellaneous
Equivalents
Forms
Games
IE4+ Scripts
IE5+ Scripts
Image Effects
Image Miscellaneous
Links & Buttons
Math Related
Messages Miscellaneous
Miscellaneous
Mouse Tricks
Navigation
Page Details
Password Protection
Pulldown Menus
Random Stuff
Scrolling
Status Bar
Text Animation
User Detail
User Info
Window Control
Length Converter
[View Sample]
This JavaScript allows to convert units from one to another. Simply choose the unit you want to use, type the value in the field next to it, and click the 'Convert' button
Insert into <HEAD>
Insert into <BODY>
<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 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 = 160934.708789 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> <div align="center"><h1>Length Converter</h1></div> <p>Simply choose the unit you want to use, type the value in the field next to it, and click the 'Convert' button.</p> <div align="center"><form name="convert"> <table border=1> <tr><th>Unit</th><th>Number</th></tr> <tr> <td> <select name="unit"> <option value="CM">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 </select> </td> <td> <input type="text" name="InUnit" size="20" maxlength="20" value="0"> </td> </tr> <tr> <td> Centimetre: </td> <td> <input type="text" name="cm" size="20" maxlength="20" value="0" onFocus="nofocus()"> </td> </tr> <tr> <td> Metre: </td> <td> <input type="text" name="m" size="20" maxlength="20" value="0" onFocus="nofocus()"> </td> </tr> <tr> <td> Kilometre: </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 align="center"> <input type="Reset" value="Start Over"> </td> <td align="center"> <input type="button" value="Convert" onClick="toCM()"> </td> </tr> </table> </form> </div>
Other Options