如题
我刚学这东西 请大家用简单点的代码写好发我
功能实现就像windos的计算器一样
比如按下11就显示11,在按下+就显示+,在按下第二个数就显示第二个数,最后按=就显示结果 QQ 393980501
我的图在下面~
如题
我刚学这东西 请大家用简单点的代码写好发我
功能实现就像windos的计算器一样
比如按下11就显示11,在按下+就显示+,在按下第二个数就显示第二个数,最后按=就显示结果 QQ 393980501
我的图在下面~
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>计算器</title>
<style>
*{
font-family:Arial, Helvetica, sans-serif;
}
td {
background-color:#FFFFFF;
height:48px;
text-align:center;
vertical-align:middle;
}
input {
font-size:19px;
width:65px;
}
</style>
</head>
<body bgcolor="#CCCCCC">
<table width="780" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000" align="center">
<tr>
<td height="0" colspan="10" align="center">
<input name="rsTxt" type="text" size="40" />
<input name="back" type="button" value="←" onclick="back1();" />
</td>
</tr>
<tr>
<td><input type="button" name="Submit" value="7" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit2" value="8" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit3" value="9" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="+" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="0x" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="PI" onclick="mathFunc(this.value,2)" /></td>
<td><input type="button" name="Submit4" value="sin" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit47" value="asin" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit43" value="log" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit42" value="ln" onclick="mathFunc(this.value,0)" /></td>
</tr>
<tr>
<td><input type="button" name="Submit5" value="4" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit6" value="5" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit7" value="6" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit8" value="-" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="A" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="D" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="cos" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit410" value="acos" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit43" value="isNaN" onclick="mathFunc(this.value,3)" /></td>
<td><input type="button" name="Submit45" value="e" onclick="mathFunc('E',2)" /></td>
</tr>
<tr>
<td><input type="button" name="Submit9" value="1" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit10" value="2" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit11" value="3" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit12" value="*" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="B" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="E" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="tan" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit413" value="atan" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit49" value="abs" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit48" value="max" onclick="mathFunc(this.value,1)" /></td>
</tr>
<tr>
<td><input type="button" name="Submit13" value="0" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit14" value="." onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit15" value="AC" onclick="clearResult();" /></td>
<td><input type="button" name="Submit16" value="/" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="C" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="F" onclick="inputChar(this.value)" /></td>
<td><input type="button" name="Submit4" value="ctn" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit472" value="atan2" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit412" value="exp" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit411" value="min" onclick="mathFunc(this.value,1)" /></td>
</tr>
<tr>
<td colspan="4" align="center"><input type="button" name="Submit17" value="= [ENTER]" onclick="evalValue();" /></td>
<td><input type="button" name="Submit13" value="(" onclick="inputChar('(')" /></td>
<td><input type="button" name="Submit13" value=")" onclick="inputChar(')')" /></td>
<td><input type="button" name="Submit46" value="sqrt" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit462" value="pow" onclick="mathFunc(this.value,1)" /></td>
<td><input type="button" name="Submit13" value="round" onclick="mathFunc(this.value,0)" /></td>
<td><input type="button" name="Submit13" value="Rnd" onclick="mathFunc('random',0)" /></td>
</tr>
</table>
<div id="result"></div>
<script language="javascript" type="text/javascript">
function inputChar(chr){
rsTxt.value+=chr;
}
function evalValue(){
rsTxt.value=eval(rsTxt.value);
}
function back1(){
rsTxt.value=rsTxt.value.substr(0,rsTxt.value.length-1);
}
function clearResult(){
rsTxt.value="";
}
function mathFunc(funcName,type){
if(type==0) rsTxt.value+="Math."+funcName+"()"; //单变量函数
if(type==1) rsTxt.value+="Math."+funcName+"(,)"; //双变量函数
if(type==2) rsTxt.value+="Math."+funcName; //常数
if(type==3) rsTxt.value+=funcName+"()"; //常数
}
//-- QQ24109068
</script>
</body>
</html>
这个太简单了,你加我Q
9704-55-399