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

JavaScript/2011년스터디/서지혜

From ZeroWiki
Revision as of 07:21, 11 January 2011 by 165.194.51.250 (talk)

<!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>


old = new Array();
function init(){

document.f.t.value = ""; isOp=false; str=0; operator="";

}
function puts(value) {

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

}
function operator(value) {

value = document.f.t; isOp = true; operator = value;

}
function calc() {

str = eval(str + operator + document.f.t.str); 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=calc("/") 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=calc("*") 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=calc("-") 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=calc("+") value="+" class=btn></td><td width="40">
<input type=button onclick=calc("%") value="%" class=btn></td>
 </td></tr>

<tr> <td colspan=2>

<input type=button onclick=adj(0) value="지우기" class=btn2></td><td colspan=3>
<input type=button onclick=sol() value="계산하기" class=btn2></td>

</form> </table>

</body>

</html>