使用js,css,html做的web版的计算器

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

class="bott2" />
<input type="button" name="9" value="9" onclick="getNum(9)"
class="bott2" />
<input type="button" name="*" value="*" onclick="getNum('*')"
function getNum(num) { var objresult = document.getElementById("result"); if (clearFlag) { objresult.value = ""; clearFlag = false; } if(typeof num=='string'&&num!='.'){ clearFlag = true; str=str+num; anFh = true; }else{ str1=objresult.value; str1 += num; str=str+num; objresult.value = str1; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html>
<head> <title>jsq.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3" /> <meta http-equiv="description" content="this is my page" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
} }
} function anJj() {
var objresult = document.getElementById("result"); xshi = Number(objresult.value); var stri=xshi+""; xshi = 0 - xshi; objresult.value = xshi + ""; str=str.substr(0,str.length-stri.length)+objresult.value; }
function anDaoshu() { var objresult = document.getElementById("result"); xshi=Number(objresult.value); var stri=xshi+""; if (anEqueal) { if (xshi != 0) { xshi = 1 / xshi; objresult.value = xshi + ""; } else { objresult.value = "除数不能为零"; }
}
function getResult() { var objresult = document.getElementById("result"); objresult.value =eval(str); str=objresult.value; anEqueal=true;
}
function anBfh() { var objresult = document.getElementById("result"); xshi = Number(objresult.value); var stri=xshi+""; if (anFh) { var s=str.substr(0,str.length-stri.length-1); var re=eval(s); var res=Number(re); xshi = res * xshi / 100; objresult.value = xshi + "";
} else { if (xshi >= 0) { xshi = Math.sqrt(xshi); result = xshi; objresult.value = xshi + ""; str=str.substr(0,str.length-stri.length)+objresult.value; } else { objresult.value = "函数输入无效"; }
} else { objresult.value = "函数输入无效";
} } else {
if (anFh) { if (xshi >= 0) { xshi = Math.sqrt(xshi); objresult.value = xshi + ""; str=str.substr(0,str.length-stri.length)+objresult.value; } else { objresult.value = "函数输入无效"; }
<script language="javascript" type="text/javascript">
var anEqueal = false; var anFh = false; var xshi = 0; var result = 0; var str = ""; var str1 = ""; var clearFlag = true;
onclick="anBackspace()" class="bott1 color" />
<input type="button" name="CE" value="CE" onclick="anCE()"
ห้องสมุดไป่ตู้
class="bott1 color" />
<input type="button" name="C" value="C" onclick="anC()"
} else { if (anFh) { if (xshi != 0) { xshi = 1 / xshi; objresult.value = xshi + ""; str=str.substr(0,str.length-stri.length)+objresult.value;
} else { objresult.value = "除数不能为零";
} } function anSqrt() {
var objresult = document.getElementById("result"); xshi = Number(objresult.value); var stri=xshi+""; if (anEqueal) {
if (xshi >= 0) { xshi = Math.sqrt(xshi); objresult.value = xshi + ""; str=str.substr(0,str.length-stri.length)+objresult.value;
} } else {
if (xshi != 0) { xshi = 1 / xshi; result = xshi; objresult.value = xshi + "";
} else { objresult.value = "除数不能为零";
} } } }
</script>
</head>
<body>
str = str.substr(0,str.length-stri.length)+objresult.value; } else {
result = 0; xshi = 0; str = ""; anFh = false; anEqueal = false; objresult.value = ""; str = str.substr(0,str.length-stri.length)+objresult.value; } }
<form action="#" method="get">
<table class="cxtable">
<tr><td><input type="text" name="result" id="result" class="cl"
value="0."/></td></tr>
<tr><td><input type="button" name="Backspace" value="Backspace"
function anC() { var objresult = document.getElementById("result"); objresult.value = "0."; str = ""; str1 = ""; anFh = false; anEqueal = false; clearFlag = true;
}
function anCE() { var objresult = document.getElementById("result"); str = str.substr(0,str.length-objresult.value.length); objresult.value = "0."; anFh = false; anEqueal = false; clearFlag = true;
<style type="text/css"> body {
width: 320px; height: 280px; margin: auto; margin-top: 100px; } table.cxtable { width: 100%; background-color: #ABCDEF; border-collapse: collapse; } table.cxtable tr td input.cl { border: 2px; width: 314px; height: 30px; font-size: 20px; font-weight: lighter; } .color { color: red; } .bott1 { width: 102.25px; height: 35px; } .bott2 { width: 60px; height: 45px; } </style>
str=str.substr(0,str.length-stri.length)+objresult.value; }else{
var str0 = xshi / 10 + ""; xshi = parseInt(str0); objresult.value = xshi + ""; str=str.substr(0,str.length-stri.length)+objresult.value; objresult.value = "0."; clearFlag = true; }
class="bott1 color" /></td></tr>
<tr><td><input type="button" name="7" value="7" onclick="getNum(7)"
class="bott2" />
<input type="button" name="8" value="8" onclick="getNum(8)"
}
function anBackspace() { var objresult = document.getElementById("result"); xshi = Number(objresult.value); var stri=xshi+""; if (xshi < 1 && xshi > 0) { var s = objresult.value; objresult.value = s.substr(0, s.length - 1); str = str.substr(0,str.length-stri.length)+objresult.value; } else { if(xshi>9||xshi<-9){ var str0 = xshi / 10 + ""; xshi = parseInt(str0); objresult.value = xshi + "";
相关文档
最新文档