JavaScript Scripts





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Free Java Script Codes
Javascript List All
Slide Show Slide Show
Ad Display Ad Display
Image Effect Image Effect
Animated Image Effects Animated Image Effects
Form Validation Form Validation
Color Picker Tool Color Picker Tool
Formatting Forms Formatting Forms
Select All Select All
Dynamic Form Select Dynamic Form select
Dynamic Color Dynamic Color
Calendar Script Calendar
Textbox Counter Textbox Counter
Alphanumeric Alphanumeric
Date Time Script Date & Time
Stop Watch Script Stop Watch script
Delete Repeated Values Delete Repeated Values
Pagination Pagination
Random Generator Random Generator
Animated Text Animated Text
Cursor Position Cursor Position
User Info Window / User Info
Security Security / Authenticate
Bookmark Bookmark
Mouse Effects Mouse Effects
Title Bar Title Bar
Status Bar Status Bar
Country List Country List
Free Games Free Games
Calculators Calculators
 




Length Calculator or Unit Conversion in javascript


About
This is a Length calculator or unit conversion script, which converts any of the entered unit(inches, feet, centimeter, kilometer, mile) to all other units including inches(in), feet(ft), centimeter(cm), kilometer(km), mile(mile).


Features
a) The javascript function will help you to calculate or convert inches(in) to feet(ft),centimeter(cm), kilometer(km),mile and vice versa.
b) If you change the value for particular unit, conversion is automatically done for all other units.
c) The value is rounded to two decimal point.
d) Just copy the code in to your page and use it.

Preview
Length calculator or Unit Conversion script

Length calculatorH
inch
cm
feet
kilo
Mile



Code
Javascript Code
<!-- Script by hscripts.com -->
<script type="text/javascript">
function checnum(as)
{
	var dd = as.value;
	
	if(isNaN(dd))
	{
		dd = dd.substring(0,(dd.length-1));
		as.value = dd;
	}		
}
function inchconv(val){
  with(document.conv){
	cm.value = (Math.round(inch.value*2.54)).toFixed(2);
	feet.value=(Math.round(inch.value/12)).toFixed(2);
	var tmp=(inch.value* 2.54)*Math.pow(10,-5);
	kilo.value=((inch.value* 2.54)*Math.pow(10,-5)).toFixed(2);
	miles.value=((inch.value*1.58)*Math.pow(10,-5)).toFixed(2);
  }
} 
function feetconv(val){
  with(document.conv){
	cm.value=(Math.round(feet.value*30.48)).toFixed(2);
	inch.value=(Math.round(feet.value*12)).toFixed(2);
	kilo.value=((feet.value* 3.05)*Math.pow(10,-4)).toFixed(2);
	miles.value==((feet.value*1.8900000000000001)*Math.pow(10,-4)).toFixed(2);
  }
}
function cmconv(val){
  with(document.conv){
	feet.value = (Math.round(cm.value/30.84)).toFixed(2);
	inch.value = (Math.round(cm.value/2.54)).toFixed(2);
	kilo.value=((cm.value*1)*Math.pow(10,-5)).toFixed(2);
	miles.value==((cm.value*6.21)*Math.pow(10,-6)).toFixed(2);
  }
}
function kiloconv(val){
  with(document.conv){
	feet.value = ((kilo.value*3.28)*Math.pow(10,3)).toFixed(2);
	inch.value = ((kilo.value*3.94)*Math.pow(10,4)).toFixed(2);
	cm.value=((kilo.value*1)*Math.pow(10,5)).toFixed(2);
	miles.value=((kilo.value* 0.621)).toFixed(2);
  }
}
function milesconv(val){
  with(document.conv){
	feet.value =((miles.value* 5.28)*Math.pow(10,3)).toFixed(2);
	inch.value = ((miles.value*6.34)*Math.pow(10,4)).toFixed(2);
	cm.value=((miles.value*1.61)*Math.pow(10,5)).toFixed(2);
	kilo.value=((miles.value*1.61)).toFixed(2);
  }
}
</script> 
<!-- Script by hscripts.com -->


HTML CODE
<form name=conv>
<table style='border:green solid 1px;font-size:12px'width=220 height=50>
    <tr><td>Length calculator</td><td align=right><a style='font-size:13px; text-decoration:none; color:#3D366F;cursor:pointer' href='http://www.hscripts.com'>H</a></td></tr>
    <tr><td align=center><input onkeyUp="checnum(this);inchconv();" value=1 name=inch></td><td>inch</td></tr>
    <tr><td align=center><input  onkeyUp="checnum(this);cmconv();" value=2.25 name=cm  ></td><td>cm</td></tr>
    <tr><td align=center><input onkeyUp="checnum(this);feetconv();" value=0 name=feet  ></td><td>feet</td></tr>
    <tr><td align=center><input onkeyUp="checnum(this);kiloconv();" value=0 name=kilo ></td><td>kilo</td></tr>
    <tr><td align=center><input onkeyUp="checnum(this);milesconv();" value=0 name=miles></td><td>Miles</td></tr>
 </table>
</form>
<br>

Release Date - 07-04-2008
Get free version without ©copyright link for just 5 price

For customization of this script or any script development, contact us at support@hscripts.com


Usage
Here we have explained with a form
a) Creating the form using following HTML code
    <form name=conv><table><tr><td></td></tr>
    <tr><td>
        <input onkeyUp="checnum(this);inchconv();"name=inch>inch
    </td></tr>
    <tr><td >
        <input onkeyUp="checnum(this);cmconv();" name=cm >cm
    </td></tr>
    <tr><td >
        <input onkeyUp="checnum(this);feetconv();" name=feet >feet
    </td></tr>
    <tr><td >
        <input onkeyUp="checnum(this);kiloconv();" name=kilo >kilo
    </td></tr>
    <tr><td >
        <input onkeyUp="checnum(this);milesconv();" name=miles>Mile
    </td></tr>
    </form></table><br>
b) The javascript function inchconv(), cmconv(), feetconv(), kiloconv(), milesconv() is triggered and Length or Unit conversion is done when key is released in the appropriate field.
c) Just copy the javascript code and use it for free.



License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.
Other Links

web hosting