计算不显示结果是为什么?
问题描述
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
section{
background-color:#c9e495;
width:280px;
height:330px;
text-align:center;
padding-top:1px;}
.textBaroder{
border-width:1px;
border-style:solid;}
</style>
</head>
<body>
<section>
<h1>
<img src="image/logo.jpg" width="260" height="31">欢迎来到淘宝!
</h1>
<form action="" method="post" name="myform" id="myform">
<h3>
<img src="file:///F|/17网页/计算机/image/购物车.jpg" width="54" height="54">购物简易计算器
</h3>
第一个数<input name="txtNum1" type="text" class="textBaroder" id="txtNum1" size="25">
第二个数<input name="txtNum2" type="text" class="textBaroder" id="txtNum2" size="25">
<input name="addButton2" type="button" id="addButton2" value=" + " onChange="compute('+')">
<input name="subButton2" type="button" id="subButton2" value=" - " onChange="compute('-')">
<input name="mulButton2" type="button" id="mulButton2" value=" × " onChange="compute('*')">
<input name="divButton2" type="button" id="divButton2" value=" ÷ " onChange="compute('/')">
计算结果<INPUT name="textResult" type="text" class="textBaroder" id="textResult" size="25">
</form>
</section>
<script>
function compute(op)
{
var num1,num2;
num1 = oarseFloat(document.myform.txtNum1.value);
num2 = oarseFloat(document.myform.txtNum2.value);
if (op=="+")
document.myform.txtResult.value = num1+num2;
if (op=="-")
document.myform.txtResult.value = num1-num2;
if (op=="*")
document.myform.txtResult.value = num1*num2;
if (op=="/" && num2!=0)
document.myform.txtResult.value = num1/num2;
}
</script>
</body>
</html>
问题解答
回答1:http://b68z56d.cn/梁丘靖之资讯网出炉
回答2:http://sn4r209.cn/淳于寄风资讯网续约
回答3:1.oarseFloat?parseFloat?属实迷惑,2.还有一个问题,txtResult错了 3.onChange能用吗?换成onclick
相关文章:
1. python 计算两个时间相差的分钟数,超过一天时计算不对2. java - web端百度网盘的一个操作为什么要分两次请求服务器, 有什么好处吗3. docker不显示端口映射呢?4. 正在使用electron和node.js做桌面应用,需要实时监听是否有网络连接,node或者electron是否可以做到5. 做Redis集群的时候,可不可以将Master实例和Slave实例放在一个主机当中?6. docker容器呢SSH为什么连不通呢?7. node.js - express框架,设置浏览器从缓存中读取静态文件,只有js从缓存中读取了,css还有一些图片为何没有从缓存中读取?8. python - flask post提交timestamp不能作为参数,这是为什么?9. java - Spring boot 读取 放在 jar 包外的,log4j 配置文件,系统有创建日志文件,不写入日志信息。10. vue.js - vue-router开启HTML5的history模式后nginx配置

网公网安备