/*整数的四则运算*/

怎么把结果直接在文本框里显示还没研究出来

<!DOCTYPE html>
<html>
  <head>
    <title>JS.html</title>
    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  
    <script>
        var a, b, op, res;
        a = "";
        b = "";
        op = "";
        function getData(obj){
            if(isNaN(parseFloat(obj.value)))
                op += obj.value;
            else{
                if(op == "")
                        a += obj.value;
                else
                    b += obj.value;
            }
        }
        function Clear(){
            if(a != "" || b != "")
                if(confirm("是否重新输入参数?")){
                    a = "";
                    b = "";
                    op = "";
                }
        }
        function show(){
            var res = 0;
            var    v1 = parseFloat(a);
            var    v2 = parseFloat(b);
            if(op == "+"){
                res = v1 + v2;
                document.write(res);
            }
            else if(op == "-"){
                res = v1 - v2;
                document.write(res);
            }
            else if(op == "*"){
                res = v1 * v2;
                document.write(res);
            }
            else{
                if(parseFloat(b) == 0){
                    alert("除数不能为0,请重新输入参数");
                    b = "";
                }
                else{
                    res = v1 / v2;
                    document.write(res);
                }
            }
            a = "";
            b = "";
            op = "";
        }
    </script>
    <style>
        .t1{
            width:200px;
            height: 200px;
            border: 1px gray solid;
            cellspacing: 200px;
        }
        
        .t1 th, tr td{
            border: 1px pink solid;
        }
        
        .t1 tr td{
            width: 45px;
        }
    </style>
  </head>
  
  <body style="width: 600px; height: 500px; margin: 0 auto">
    <div id="d1" style="width: 600px; height: 500px; background-image: url(../Image/1.jpg)">
        <div style="width: 600px; height: 150px;"></div>
        <table align="center" class="t1">
            <th align="center" colspan="4"><font style="color: purple; font-style: italic;">计算器</font></th>
            <tr>
                <td align="center"><input type="button" value="1" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="2" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="3" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="+" onclick="getData(this)"></td>
            </tr>
            <tr>
                <td align="center"><input type="button" value="4" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="5" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="6" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="-" onclick="getData(this)"></td>
            </tr>
            <tr>
                <td align="center"><input type="button" value="7" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="8" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="9" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="*" onclick="getData(this)"></td>
            </tr>
            <tr>
                <td align="center"><input type="button" value="0" onclick="getData(this)"></td>
                <td align="center"><input type="button" value="C" onclick="Clear()"></td>
                <td align="center"><input type="button" value="=" onclick="show()"></td>
                <td align="center"><input type="button" value="/" onclick="getData(this)"></td>
            </tr>
        </table>
    </div>
  </body>
</html>

 

//网页效果如下