A simple centimeter, inches, and feet conversion and vice versa using JavaScript programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.

Program Listing

<html>
   <title>Centimeter, Inches, and Feet Conversion in JavaScript  </title>
 <style type="text/css">

 body {

 	font-family: arial;
 	font-weight: bold;
 	font-size:15px;
 	 }
 
 form
{
  display: inline-block;
  background-color: lightblue;
  padding: 6px;
}

label{
  display: block;
  direction: rtl; 
}

input{
  direction: ltr; 
}

label::after{
  content: attr(data-text);
}
 </style>

<script language="JavaScript">

function cmConverter(){
document.converter.inch.value = (document.converter.cm.value / 2.54).toFixed(2);
document.converter.feet.value = (document.converter.cm.value / 30.48).toFixed(2);
}
function inchConverter(){
document.converter.cm.value = (document.converter.inch.value * 2.54).toFixed(2);
document.converter.feet.value = (document.converter.inch.value / 12).toFixed(2);
}
function feetConverter(){
document.converter.cm.value = (document.converter.feet.value * 30.48).toFixed(2);
document.converter.inch.value = (document.converter.feet.value * 12).toFixed(2);
}

function Clear() {
document.converter.cm.value ="";
document.converter.feet.value="";
document.converter.inch.value="";
document.converter.cm.focus();
 
}

</script>
<body>
<br>
<h3>Centimeter, Inches, and Feet Conversion in JavaScript</h3>
<form name="converter">
<label data-text="Centimeter">&nbsp;&nbsp;	
<input type="text" name="cm" onChange="cmConverter()" required="">
</label>
<br />
<label data-text="Inches">&nbsp;&nbsp;
<input type="text" name="inch" onChange="inchConverter()" required="">
</label>
<br/>
<label data-text="Feet">&nbsp;&nbsp;<input type="text" name="feet" onChange="feetConverter()" required="">
</label>
<br /> <br>
<input type="button" value="Convert" title="Click here to convert." />
<input type="button" value="Clear"  
title="Click here to clear the text box."
onclick="Clear()"/>
</form>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *