足し算

parseInt + parseInt

<!DOCTYPE html>
<html la="ja">
<head>
    <meta charset="utf-8">
    <title>JS</title>
    <style>
        input {
            width: 50px;
        }
    </style>
</head>
<body>
<form name="f">
    <input type="text" name="f1">+
    <input type="text" name="f2">
    <input type="button" name="submit" value="計算" onclick="x()">
    <input type="text" name="f3" disabled="disable">
</form>
<script type="text/javascript">
    function x() {
        var a = document.f.f1.value;
        var b = document.f.f2.value;
        var c = parseInt(a)+parseInt(b);

        document.f.f3.value = c;
    }
</script>
</body>
</html>

f:id:hrt0kmt:20141008173650p:plain