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 60: Line 60:
   <input type=button onclick=putn(8) value=8 class=btn></td><td width="41">
   <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=putn(9) value=9 class=btn></td><td width="40">
   <input type=button onclick=calc("/") value="/" 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>
   <input type=button  value="pow" class=btn></td></tr>
  <tr><Td width="40" height="25">
  <tr><Td width="40" height="25">
Line 69: Line 69:
   <input type=button onclick=putn(6) value=6 class=btn></td>
   <input type=button onclick=putn(6) value=6 class=btn></td>
   <td width="40" height="25">
   <td width="40" height="25">
   <input type=button onclick=calc("*") value="*" class=btn></td>
   <input type=button onclick=operator("*") value="*" class=btn></td>
   <td width="40" height="25">
   <td width="40" height="25">
   <input type=button  value="sqrt" class=btn></td></tr>
   <input type=button  value="sqrt" class=btn></td></tr>
Line 76: Line 76:
   <input type=button onclick=putn(2) value=2 class=btn></td><td width="41">
   <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=putn(3) value=3 class=btn></td><td width="40">
   <input type=button onclick=calc("-") value="-" 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>
   <input type=button  value="log" class=btn></td></tr>
  <tr><td width="40">
  <tr><td width="40">
   <input type=button onclick=putn(0) value=0 class=btn></td><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=putn('.') value=. class=btn></td><td width="41">
   <input type=button onclick=calc("+") value="+" class=btn></td><td width="40">
   <input type=button onclick=operator("+") value="+" class=btn></td><td width="40">
   <input type=button onclick=calc("%") value="%" class=btn></td>
   <input type=button onclick=operator("%") value="%" class=btn></td>
    </td></tr>
    </td></tr>
   
   
  <tr>
  <tr>
  <td colspan=2>
  <td colspan=2>
   <input type=button onclick=adj(0) value="지우기" class=btn2></td><td colspan=3>
   <input type=button value="지우기" class=btn2></td><td colspan=3>
   <input type=button onclick=sol() value="계산하기" class=btn2></td>
   <input type=button onclick=calc() value="계산하기" class=btn2></td>
   
   
  </form>
  </form>

Revision as of 07:35, 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;
	operator="";
 }

 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) {
	value = document.f.t.value;
	isOp = true;
	operator = value;
 }

 function calc() {
	str = eval(str + operator + document.f.t.value);
	document.f.t.value = str;
 }

 </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 onclick=operator("%") value="%" class=btn></td>
  </td></tr>

<tr>
<td colspan=2>
 <input type=button value="지우기" class=btn2></td><td colspan=3>
 <input type=button onclick=calc() value="계산하기" class=btn2></td>

</form>
</table>
 </body>
</html>