How to Convert from Meters to Centimeters Using Javascript With HTML?

Certainly! You can create a simple HTML page with JavaScript to convert meters to centimeters. Here’s an example:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Meters to Centimeters Converter</title>
</head>
<body>
<h2>Meters to Centimeters Converter</h2>
<label for="metersInput">Enter Meters:</label>
<input type="number" id="metersInput" placeholder="Enter meters" oninput="convertToCentimeters()">
<p id="result"></p>
<script>
function convertToCentimeters() {
// Get the value entered in meters input
var meters = document.getElementById("metersInput").value;
// Convert meters to centimeters (1 meter = 100 centimeters)
var centimeters = meters * 100;
// Display the result
document.getElementById("result").innerHTML = meters + " meters is equal to " + centimeters + " centimeters.";
}
</script>
</body>
</html>

In this example, we have an input field where the user can enter the length in meters. The `convertToCentimeters` function is called whenever the input value changes. The function then takes the entered value, multiplies it by 100 (since 1 meter equals 100 centimeters), and displays the result in the paragraph with the id “result”.