Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
818 B
2
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form onsubmit="calculate(event)">
        Enter radius: <input type="number" id="radius" required>
        <button type="submit">Submit</button>
    </form>
    <br>
    <div id="output"></div>

    <script>
        function calculate(event) {
            event.preventDefault(); // Prevent form submission
            var pi = 3.14;
            var r = document.getElementById("radius").value;
            var a = pi * r * r;
            var c = 2 * pi * r;
            document.getElementById("output").innerHTML = "Area = " + a + "<br>Circumference = " + c;
        }
    </script>
</body>
</html>
Leave a Comment