計(jì)算不顯示結(jié)果是為什么?
問(wèn)題描述
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無(wú)標(biāo)題文檔</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">歡迎來(lái)到淘寶!
</h1>
<form action="" method="post" name="myform" id="myform">
<h3>
<img src="file:///F|/17網(wǎng)頁(yè)/計(jì)算機(jī)/image/購(gòu)物車.jpg" width="54" height="54">購(gòu)物簡(jiǎn)易計(jì)算器
</h3>
第一個(gè)數(shù)<input name="txtNum1" type="text" class="textBaroder" id="txtNum1" size="25">
第二個(gè)數(shù)<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('/')">
計(jì)算結(jié)果<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>
問(wèn)題解答
回答1:http://b68z56d.cn/梁丘靖之資訊網(wǎng)出爐
回答2:http://sn4r209.cn/淳于寄風(fēng)資訊網(wǎng)續(xù)約
回答3:1.oarseFloat?parseFloat?屬實(shí)迷惑,2.還有一個(gè)問(wèn)題,txtResult錯(cuò)了 3.onChange能用嗎?換成onclick
相關(guān)文章:
1. 正則表達(dá)式 - python pandas的sep參數(shù)問(wèn)題2. javascript - ionic run android報(bào)錯(cuò)3. mysql - SQL操作時(shí)間的函數(shù)?4. MYSQL新建用戶設(shè)置可以遠(yuǎn)程訪問(wèn)的問(wèn)題5. python - 求一個(gè)在def中可以實(shí)現(xiàn)調(diào)用本def滿足特定條件continue效果的方法(標(biāo)題說(shuō)不太清楚,請(qǐng)見(jiàn)題內(nèi)描述)6. angular.js - angularjs的自定義過(guò)濾器如何給文字加顏色?7. docker內(nèi)創(chuàng)建jenkins訪問(wèn)另一個(gè)容器下的服務(wù)器問(wèn)題8. javascript - 用表單提交兩個(gè)時(shí)間段請(qǐng)求后臺(tái)返回對(duì)應(yīng)數(shù)據(jù)時(shí)出現(xiàn)的一些問(wèn)題!9. node.js - mongoDB使用$gte的問(wèn)題10. node.js - nodejs和前端JavaScript 字符串處理結(jié)果不一樣是什么原因?
