Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a speed converter with HTML and JavaScript?
To create a speed converter with HTML and JavaScript, the code is as follows −
Example
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
input, span {
font-size: 20px;
}
</style>
</head>
<body>
<h1>Speed Converter</h1>
<h2>Type speed in Kilometer per hour to convert it into meter per hour</h2>
<p>
<label>Kilometer Per Hour</label>
<input
id="inputKm"
type="number"
placeholder="KilometersPerHour"
oninput="KmphtoMphConverter(this.value)"
onchange="KmphtoMphConverter(this.value)"/>
</p>
<p>Meters Per second: <span class="metersPerSecond"></span></p>
<script>
function KmphtoMphConverter(speed) {
document.querySelector(".metersPerSecond").innerHTML = speed * 0.277778;
}
</script>
</body>
</html>
Output
The above code will produce the following output −

On entering some speed in kph −

Advertisements