Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

JavaScript/2011년스터디/서지혜: Difference between revisions

From ZeroWiki
No edit summary
No edit summary
Line 1: Line 1:
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  <html>
  <html>
  <head>
   
  <title>짜가계산기</title>
    <head>
  <meta name="Generator" content="EditPlus">
        <title>
  <meta name="Author" content="">
            짜가계산기
  <meta name="Keywords" content="">
        </title>
  <meta name="Description" content="">
        <meta name="Generator" content="EditPlus">
  <meta http-equiv="Content-Type" content="text/html; charset=ks_c_5601-1987">
        <meta name="Author" content="">
  </head>
        <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();
   
   
  <body>
            function init() {
  <style>
                document.f.t.value = "";
  .btn{width:40}
                isOp = false;
  .btn2{width:88}
                str = 0;
  </style>
                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;
                }
            }
   
   
<script>
            function operator(value) {
  old = new Array();
                str = document.f.t.value;
                isOp = true;
                oprt = value;
            }
   
   
  function init(){
            function calc() {
document.f.t.value = "";
str2 = document.f.t.value;
isOp=false;
                if (str != "" && str2 != "") {
str=0;
                    str = eval(str + oprt + str2);
operator="";
                    document.f.t.value = str;
  }
                }
            }
   
   
  function putn(value) {
            function reset() {
if(!isOp){
                str = "";
document.f.t.value += value;
                document.f.t.value = "";
} else if(isOp){
                oprt = "";
document.f.t.value = value;
                isOp = false;
isOp = false;
            }
} else{
        </script>
document.f.t.value += value;
       
}
        <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>
   
   
  function operator(value) {
value = document.f.t.value;
isOp = true;
operator = value;
  }
  function calc() {
if(str != "" && document.f.t.value != ""){
str = eval(str + operator + document.f.t.value);
document.f.t.value = str;
}
  }
  function reset() {
str = "";
document.f.t.value = "";
operator = "";
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>
  </html>



Revision as of 08:09, 11 January 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>