U E D R , A S I H C RSS

JavaScript/2011년스터디/서지혜 (rev. 1.9)

Java Script/2011년스터디/서지혜

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    
    <head>
        <title>
            짜가계산기
        </title>
        <meta name="Generator" content="EditPlus">
        <meta name="Author" content="">
        <meta name="Keywords" content="">
        <meta name="Description" content="">
        <meta http-equiv="Content-Type" content="text/html; charset=ks_c_5601-1987">
    </head>
    
    <body>
        <style>
            .btn{width:40} .btn2{width:88}
        </style>
        <script>
            old = new Array();

            function init() {
                document.f.t.value = "";
                isOp = false;
                str = 0;
                oprt = "";
            }

            function putn(value) {
                if (!isOp) {
                    document.f.t.value += value;
                } else if (isOp) {
                    document.f.t.value = value;
                    isOp = false;
                } else {
                    document.f.t.value += value;
                }
            }

            function operator(value) {
                str = document.f.t.value;
                isOp = true;
                oprt = value;
            }

            function calc() {
			str2 = document.f.t.value;
                if (str != "" && str2 != "") {
                    str = eval(str + oprt + str2);
                    document.f.t.value = str;
                }
            }

            function reset() {
                str = "";
                document.f.t.value = "";
                oprt = "";
                isOp = false;
            }
        </script>
        
        <body onload=init();>
            <table border=6 width="247">
                <tr>
                    <form name=f>
                        <td colspan=5>
                            <input type=text name=t value="" size=30>
                        </td>
                </tr>
                <tr>
                    <td width="40">
                        <input type=button onclick=putn(7) value=7 class=btn>
                    </td>
                    <td width="40">
                        <input type=button onclick=putn(8) value=8 class=btn>
                    </td>
                    <td width="41">
                        <input type=button onclick=putn(9) value=9 class=btn>
                    </td>
                    <td width="40">
                        <input type=button onclick=operator("/") value="/" class=btn>
                    </td>
                    <td width="40">
                        <input type=button value="pow" class=btn>
                    </td>
                </tr>
                <tr>
                    <Td width="40" height="25">
                        <input type=button onclick=putn(4) value=4 class=btn>
                    </td>
                    <td width="40" height="25">
                        <input type=button onclick=putn(5) value=5 class=btn>
                    </td>
                    <td width="41" height="25">
                        <input type=button onclick=putn(6) value=6 class=btn>
                    </td>
                    <td width="40" height="25">
                        <input type=button onclick=operator("*") value="*" class=btn>
                    </td>
                    <td width="40" height="25">
                        <input type=button value="sqrt" class=btn>
                    </td>
                </tr>
                <tr>
                    <td width="40">
                        <input type=button onclick=putn(1) value=1 class=btn>
                    </td>
                    <td width="40">
                        <input type=button onclick=putn(2) value=2 class=btn>
                    </td>
                    <td width="41">
                        <input type=button onclick=putn(3) value=3 class=btn>
                    </td>
                    <td width="40">
                        <input type=button onclick=operator("-") value="-" class=btn>
                    </td>
                    <td width="40">
                        <input type=button value="log" class=btn>
                    </td>
                </tr>
                <tr>
                    <td width="40">
                        <input type=button onclick=putn(0) value=0 class=btn>
                    </td>
                    <td width="40">
                        <input type=button onclick=putn('.') value="." class=btn>
                    </td>
                    <td width="41">
                        <input type=button onclick=operator("+") value="+" class=btn>
                    </td>
                    <td width="40">
                        <input type=button value="%" class=btn>
                    </td>
                     
                    </td>
                </tr>
                <tr>
                    <td colspan=2>
                        <input type=button onclick=reset() value="지우기" class=btn2>
                    </td>
                    <td colspan=3>
                        <input type=button onclick="calc()" value="계산하기" class=btn2>
                    </td>
                    </form>
            </table>
        </body>

</html>
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:30
Processing time 0.0455 sec