프로그래밍

덧셈 계산기

wonjae 2022. 1. 8. 12:15

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function calc() {
            var x = document.getElementById("x").value;
            var y = document.getElementById("y").value;
            var sum;
            sum = parseInt(x) + parseInt(y);
            document.getElementById("sum").value = sum;
        }
    </script>
</head>
<body>
    <h3>덧셈 계산기</h3>
    <form name="myform" action=". . ." method="POST">
        첫번째 정수 : <input id="x" /><br />
        두번째 정수 : <input id="y" /><br />
        합계 : <input id="sum" /><br />
        <input type="button" value="계산" onclick="calc();" ?>
    </form>
</body>
</html>