购物简易计算器

Posted hanweiyan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了购物简易计算器相关的知识,希望对你有一定的参考价值。

<!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("+"); />&nbsp;
<input type="button"name="subButton2"id="subButton2"value="-" style="width:63px;height:20px;"onClick=compute("-"); />&nbsp;
<input type="button"name="mulButton2"id="mulButton2"value="*" style="width:63px;height:20px;"onClick=compute("*"); />&nbsp;
<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>

以上是关于购物简易计算器的主要内容,如果未能解决你的问题,请参考以下文章

jQuery实现购物车计算价格功能的方法

PowerApps_创建一个简易的计算器

JAVA在WEB上的应用——实现简易计算器 求代码

如何运用Python编写简易计算器

怎么在网页上制作一个简易计算器

java 简易计算器(帮我改一改,增加几个功能)