HTMLify
pounds to kg converter
Views: 146 | Author: amar
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <!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> |