导航:首页 > 万维百科 > 网页设计的计算器代码

网页设计的计算器代码

发布时间:2020-11-23 05:03:11

1、网页制作,,,公式计算器

我做了个简单的 你先拿去用吧。
把代码粘贴到html文件里面就好了。
纯手打的 望采纳。
——————————————————代码—————————————————
<html>
<head>
<title>Caculator</title>
</head>
<body>
<table>
<tr>
<td>单价:</td><td><input type="text" id="sPrice" value="" /></td>
</tr>
<tr>
<td>数量:</td><td><input type="text" id="Num" value=""/></td>
</tr>
<tr>
<td>总价:</td><td><input type="text" id="TPrice" value=""/></td>
</tr>
<tr>
<td><input type="button" id="cacul" value="计算" onclick="cal();"/></td>
</tr>
</table>
</body>
<script type="text/javascript">
function cal(){
var sPrice = document.getElementById('sPrice').value;
var Num = document.getElementById('Num').value;
var TPrice= document.getElementById('TPrice').value;
if(sPrice!=''&&Num!=''){
TPrice = sPrice*Num;
document.getElementById('TPrice').value = TPrice;
}
if(Num==0&&TPrice!=''){
alert('除数不能为零!');
}
if(TPrice!=''&&Num!=''&&Num!=0){
sPrice = TPrice/Num;
document.getElementById('sPrice').value = sPrice;
}

}
</script>
</html>

2、用css js做一个网页版的计算器,要有加减乘除运算,和归零删除键

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>计数器</title>
</head>
<body>
<input type="text" name="text" id="pre" onblur="validate(this.value);">
<select id="operator">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" name="text" id="next" onblur="validate(this.value);">
<span>=</span>
<input type="text" id="result" readonly="true">
<input type="button" id="btn" value="提交" onclick="calculator();">
<script>
function validate(str){
var reg = /^\d+$/;
if (!reg.test(str)) {
alert("请输入数字");
}
}
function calculator(){
var pre=document.getElementById("pre").value;
var next=document.getElementById("next").value;
var opra=document.getElementById("operator").value;

var result=0;
switch(opra) {
case "+":
result=parseInt(pre)+parseInt(next);
break;
case "-":
result=parseInt(pre)-parseInt(next);
break;
case "*":
result=parseInt(pre)*parseInt(next);
break;
case "/":
if(parseInt(next)!=0){
result=parseInt(pre)/parseInt(next);
}
else{
alert("除数不能为0");
return;
}
break;
default:
break;
}
document.getElementById("result").value=result;
}
</script>
</body>
</html>

3、网页计算器设计

我写了个简单的```你要的那些都有````附件

4、如何用运用html和css相关技术,设计一个网页在线计算器的界面

html+css只是静态样式。而涉及到计算方面,得再加js就能实现了。

5、网页制作--如何制作计数器?

Microsoft Frontpage有现成的.将它插入到你所希望的位置即可.

6、在自己电脑上设计的网页计算器,如何操作可以让别人通过手机打开?急,求大神指教。

将网页上传到网站,然后将这个网页的地址发给对方,对方就可以用手机打开了

7、简单的网页计算器制作,是不是我代码写错了,怎么显示的是不完整的呢?

添加点样式,或者表格来调整位置。

8、网页设计与制作设计一个页面,实现一个四则计算器

这个代码其实网上有很多现成的,而且做有CSS布局各种形式的都有,自己多花点时间搜索下就可以找到 。

与网页设计的计算器代码相关的知识