HTMLify
pounds to kg converter
Views: 36 | Author: amar
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weight Conversion Tool</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
display: flex;
flex-direction: column;
min-height: 100vh;
}
input, button {
margin: 10px 0;
padding: 8px;
font-size: 16px;
}
button {
cursor: pointer;
}
footer {
margin-top: auto;
text-align: center;
padding: 10px;
font-size: 14px;
color: #555;
border-top: 1px solid #ccc;
}
</style>
</head>
<body>
<div>
<form onsubmit="return false;">
<h1>Weight Converter (Pounds to Kg)</h1>
<p>Enter weight value in pounds:</p>
<label for="pounds">Pounds:</label>
<input type="number" id="pounds" step=".1">
<button type="button" onclick="convertWeight()">Calculate</button>
<p>Your weight in Kilograms is:
<span id="result">you need to input some digit, I can’t read mind</span>
</p>
</form>
</div>
<footer>
© 2013 – Made by Amar
</footer>
<script>
function convertWeight() {
let pounds = document.getElementById("pounds").value;
let result = document.getElementById("result");
// Step 2: show "calculating..." immediately
result.textContent = "calculating...";
setTimeout(() => {
if (pounds === "" || isNaN(pounds)) {
// Step 3: show "idk" if invalid
result.textContent = "idk";
} else {
// Otherwise, show the converted value
let kg = (pounds * 0.45359237).toFixed(2);
result.textContent = kg;
}
}, 1000); // 1 second delay
}
</script>
</body>
</html>