标签:== parse method 第一个 func class val set style
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>购物简易计算器</title>
<style>
.Compute{
width:300px;
height:400px;
}
</style>
<script>
function compute(op){
var num1,num2;
num1=parseFloat(document.myform.txtNum1.value);
num2=parseFloat(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=="/")
{
document.myform.txtResult.value=num1/num2;
}
}
</script>
</head>
<body>
<section class="Compute">
<form action=""method="post" name="myform"id="myform">
<h3>购物简易计算器</h3>
<p> 第一个数:
<input type="text" name="txtNum1"class="textBaroder"id="txtNum1"size="25"/>
<p>第二个数:
<input type="text" name="txtNum2"class="textBaroder"id="txtNum2"size="25"/>
</p>
<p>
<input type="button"name="addButton2"id="addButton2"value="+"style="width:63px;height:20px;"onClick=compute("+"); />
<input type="button"name="subButton2"id="subButton2"value="-" style="width:63px;height:20px;"onClick=compute("-"); />
<input type="button"name="mulButton2"id="mulButton2"value="*" style="width:63px;height:20px;"onClick=compute("*"); />
<input type="button"name="divButton2"id="divButton2"value="/" style="width:63px;height:20px;"onClick=compute("/"); />
</p>
<p>计算结果:
<input type="text"name="txtResult"class="textBaroder" id="txtResult"size="25"/>
</p>
</form>
</section>
</body>
</html>
标签:== parse method 第一个 func class val set style
原文地址:https://www.cnblogs.com/hanweiyan/p/11559493.html