
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
Create Length Converter with HTML and JavaScript
To create a length 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>Length Converter</h1> <h2>Type length in Kilometers to convert it into meters</h2> <p> <label>Kilometers</label> <input id="inputKm" type="number" placeholder="Kilometers" oninput="KmtoMConverter(this.value)" onchange="KmtoMConverter(this.value)"> </p> <p>Meters: <span class="meters"></span></p> <script> function KmtoMConverter(length) { document.querySelector(".meters").innerHTML=length*1000; } </script> </body> </html>
Output
The above code will produce the following output −
On entering length in kilometers −
Advertisements