Kilometers/Miles Converter


Kilometers/Miles Converter using Javascript




This simple Program will take input in Kilometers and convert it to Miles and vice versa.

HTML with Javascript


<!DOCTYPE html>
<html>
<title>Kilometers/Miles Converter</title>
<body bgcolor="lightgreen">

<h2>Kilometers/Miles Converter</h2>
<p>Type a value in Kilometers to convert to Miles:</p>

<p>
  <label>Kilometers</label>
  <input id="k" type="number" placeholder="000" oninput="Convert(this.value)" onchange="Convert(this.value)">
</p>
<p>Miles: <span id="Miles"></span></p>

<script>
function Convert(km) {
  document.getElementById("Miles").innerHTML=km*0.62137;
}
</script>

<p>Type a value in Miles to convert to Kilometers:</p>

<p>
  <label>Miles</label>
  <input id="m" type="number" placeholder="000" oninput="ConvertM(this.value)" onchange="ConvertM(this.value)">
</p>
<p>Kilometers: <span id="km"></span></p>

<script>
function ConvertM(m) {
  document.getElementById("km").innerHTML=m/0.62137;
}
</script>

</body>
    
<html>


Click here to run this Code


Share with Friends


Twitter Facebook Google LinkedIn Email Pinterest Reddit StumbleUpon Tumblr




Try these Fun Games by Bobbie:


Travel Blast Game New York


Play and Learn Russian


Battlestarship Game



Take a look at these Groovy Codes:


Fun IQ Test


Html Svg Starburst


Javascript Particles Fishes



Read the Latest Breaking Programming and Tech News, Great Articles and Tips:


Codenewz Programming and Tech News






Comments

Popular posts from this blog