<%@ Page Xlanguage="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
var numb = 0;
var numb1 = 0;
var numb2 = 0;
var numb3 = 0;
function show(obj)
{
document.getElementById('Text1').value += obj;
}
function tui() {
var s=document.getElementById('Text1').value;
document.getElementById('Text1').value = s.substring(0, s.length - 1);
}
function g() {
var s = document.getElementById('Text1').value;
var p = Math.sqrt(parseFloat(s));
document.getElementById('Text1').value = p;
}
function f() {
var s = document.getElementById('Text1').value;
document.getElementById('Text1').value = parseFloat(s) * parseFloat(s);
}
function puls() {
numb = document.getElementById('Text1').value;
document.getElementById('Text1').value = '';
}
function jian() {
numb1 = document.getElementById('Text1').value;
document.getElementById('Text1').value = '';
}
function cheng() {
numb2 = document.getElementById('Text1').value;
document.getElementById('Text1').value = '';
}
function chu() {
numb3 = document.getElementById('Text1').value;
document.getElementById('Text1').value = '';
}
function equals() {
if (numb != 0) {
document.getElementById('Text1').value = parseFloat(numb) + parseFloat(document.getElementById('Text1').value);
}
else {
if (numb1 != 0) {
document.getElementById('Text1').value = parseFloat(numb1) - parseFloat(document.getElementById('Text1').value);
}
else {
if (numb2 != 0) {
document.getElementById('Text1').value = parseFloat(numb2) * parseFloat(document.getElementById('Text1').value);
}
else {
if (numb3 != 0) {
document.getElementById('Text1').value = parseFloat(numb3) / parseFloat(document.getElementById('Text1').value);
}
else {
}
}
}
}
numb = 0;
numb1 = 0;
numb2 = 0;
numb3 = 0;
}
function c() {
document.getElementById('Text1').value = '';
}
</script>
<title></title>
<style type="text/css">
.style1
{
width: 30%;
height: 288px;
}
#Button1
{
height: 49px;
width: 56px;
}
#Button2
{
height: 49px;
width: 56px;
}
#Button3
{
height: 49px;
width: 56px;
}
#Button4
{
height: 49px;
width: 56px;
}
#Button5
{
height: 49px;
width: 56px;
}
#Button10
{
height: 49px;
width: 56px;
}
#Button9
{
height: 49px;
width: 56px;
}
#Button8
{
height: 49px;
width: 56px;
}
#Button7
{
height: 49px;
width: 56px;
}
#Button6
{
height: 49px;
width: 56px;
}
#Button19
{
height: 49px;
width: 56px;
}
#Button17
{
height: 49px;
width: 56px;
}
#Button15
{
height: 49px;
width: 56px;
}
#Button13
{
height: 49px;
width: 56px;
}
#Button11
{
height: 49px;
width: 56px;
}
#Button12
{
height: 49px;
width: 56px;
}
#Button14
{
height: 49px;
width: 56px;
}
#Button16
{
height: 49px;
width: 56px;
}
#Button18
{
height: 49px;
width: 56px;
}
#Button20
{
height: 49px;
width: 56px;
}
#Text1
{
height: 39px;
width: 289px;
}
.style2
{
text-align: center;
}
.style3
{
font-size: large;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table bgcolor="#669999" class="style1">
<tr>
<td colspan="4" class="style2">
<strong><span class="style3">计算器</span></strong><input id="Text1" type="text" /></td>
</tr>
<tr>
<td>
<input id="Button1" type="button" value="+" Xοnclick="puls()" /></td>
<td>
<input id="Button10" type="button" value="1" Xοnclick="show(1)" /></td>
<td>
<input id="Button11" type="button" value="2" Xοnclick="show(2)"/></td>
<td>
<input id="Button12" type="button" value="3" Xοnclick="show(3)"/></td>
</tr>
<tr>
<td>
<input id="Button2" type="button" value="-" Xοnclick="jian()"/></td>
<td>
<input id="Button9" type="button" value="4" Xοnclick="show(4)"/></td>
<td>
<input id="Button13" type="button" value="5" Xοnclick="show(5)"/></td>
<td>
<input id="Button14" type="button" value="6" Xοnclick="show(6)"/></td>
</tr>
<tr>
<td>
<input id="Button3" type="button" value="*" Xοnclick="cheng()"/></td>
<td>
<input id="Button8" type="button" value="7" Xοnclick="show(7)"/></td>
<td>
<input id="Button15" type="button" value="8" Xοnclick="show(8)"/></td>
<td>
<input id="Button16" type="button" value="9"Xοnclick="show(9)"/></td>
</tr>
<tr>
<td>
<input id="Button4" type="button" value="/" Xοnclick="chu()"/></td>
<td>
<input id="Button7" type="button" value="." Xοnclick="show('.')"/></td>
<td>
<input id="Button17" type="button" value="0" Xοnclick="show(0)"/></td>
<td>
<input id="Button18" type="button" value="=" Xοnclick="equals()"/></td>
</tr>
<tr>
<td>
<input id="Button5" type="button" value="√" Xοnclick="g()"/></td>
<td>
<input id="Button6" type="button" value="x²" Xοnclick="f()"/></td>
<td>
<input id="Button19" type="button" value="AC" Xοnclick="c()" /></td>
<td>
<input id="Button20" type="button" value="←" Xοnclick="tui()"/></td>
</tr>
</table>
</div>
</form>
</body>
</html>