計算不顯示結果是為什么?
問題描述
<!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網(wǎng)頁/計算機/image/購物車.jpg" width="54" height="54">購物簡易計算器
</h3>
第一個數(shù)<input name="txtNum1" type="text" class="textBaroder" id="txtNum1" size="25">
第二個數(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('/')">
計算結果<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/梁丘靖之資訊網(wǎng)出爐
回答2:http://sn4r209.cn/淳于寄風資訊網(wǎng)續(xù)約
回答3:1.oarseFloat?parseFloat?屬實迷惑,2.還有一個問題,txtResult錯了 3.onChange能用嗎?換成onclick
相關文章:
1. angular.js - 關于$apply()2. angular.js使用$resource服務把數(shù)據(jù)存入mongodb的問題。3. MySQL數(shù)據(jù)庫中文亂碼的原因4. dockerfile - [docker build image失敗- npm install]5. dockerfile - 我用docker build的時候出現(xiàn)下邊問題 麻煩幫我看一下6. 如何解決Centos下Docker服務啟動無響應,且輸入docker命令無響應?7. android-studio - Android Studio 運行項目的時候一堆警告,跑步起來!?8. nignx - docker內(nèi)nginx 80端口被占用9. angular.js - Ionic 集成crosswalk后生成的apk在android4.4.2上安裝失敗???10. mysql - 新浪微博中的關注功能是如何設計表結構的?
