JavaScript帮忙修改下

来源:百度知道 编辑:UC知道 时间:2024/06/20 10:52:27
<html>
<head>
<title>Caculate</title>
<script language="javascript">
var a,b,result;
var fuhao;

function fuzhi(v) {
document.frm.show.value+=v;
}
function operation(m){
a=document.frm.show.value;
fuhao=m;
document.frm.show.value="";
}
function cal(){
b=document.frm.show.value;
switch(fuaho){
case '+':result=parseFloat(a)+parseFloat(b);break;
case '-':result=parseFloat(a)-parseFloat(b);break;
case '*':result=parseFloat(a)*parseFloat(b);break;
case '/':result=parseFloat(a)/parseFloat(b);break;
default:alert=("error");
}
document.frm.show.value=result;
}
function clean(){
show.value="";
}
</script>
</head>

<body>
<form name="frm">
<table align=&qu

该好了。你运行下看看效果。如果有问题欢迎交流。
<html>
<head>
<title>Caculate</title>
<script language="javascript">
var a,b,result;
var fuhao;

function fuzhi(v)
{
if(v=='d')
v='.';
document.getElementById("show").value+=v;
}
function operation(m)
{
a=document.getElementById("show").value;
fuhao=m;
document.getElementById("show").value="";
}
function cal()
{
b=document.getElementById("show").value;
switch(fuhao){
case '+':result=parseFloat(a)+parseFloat(b);break;
case '-':result=parseFloat(a)-parseFloat(b);break;
case '*':result=parseFloat(a)*parseFloat(b);break;
case '/':result=parseFloat(a)/parseFloat(b);break;
default:alert("error");
}
document.getElementById("sho