不是那个错误了,我已经改正了,但现在还有错误,
<html>
<head>
<title>计算器</title>
<script langeage="JavaScript">
var inputs="",s1=0,s2=0,s3=0,clear=false,xcase=0,yuns="",dd,snum,sb;
function cstr(value)
{
dd=new String(document.all.calc.input.value)
snum=new String("0123456789")
sb=new String(".+-*/=")
if (clear==true)
document.all.calc.input.value=""
if (sb.indexOf(value)==0) && (dd.indexOf(value)==-1)//这里有错呀
xcase=1
for (i=1;i<=4;i++)
{
if sb.indexOf(value)=i
{
xcase=2
yuns=sb.substring(i,i+1)
}
}
if sb.indexOf(value)=sb.length-1
xcase=3
if value=="c"
xcase=0
for (i=0;i<10;i++)
{
if snum.indexOf(value)=i
{
xcase=4
break;
}
}
switch xcase
{
case 0:
document.all.calc.input.value =""
break;
case 1:
inputs+=value
document.all.calc.input.value=inputs
break;
case 2:
s1=parseFloat(document.all.calc.input.value)
clear=true
break;
case 3:
s2=parseFloat(document.all.calc.input.value)
if yuns=="+"
s3=s1+s2
if yuns=="-"
s3=s1-s2
if yuns=="*"
s3=s1*s2
if yuns=="/"
s3=s1/s2
document.all.calc.input.value=s3.toString()
clear=true
break;
xcase=4:
inputs+=value
document.all.calc.input.value=inputs
break;
}
}
</script>
</head>
<body>
<center>
<h1>红君<h1>
<hr>
<br>
<form id="calc">
<input type="text" id="input" size="22">
<br>
<input type="button" name="z1" value="1" onclick="cstr('1')">
<input type="button" name="z2" value="2" onclick="cstr('2')">
<input type="button" name="z3" value="3" onclick="cstr('3')">
<input type="button" name="l1" value="+" onclick="cstr('+')">
<br>
<input type="button" name="z4" value="4" onclick="cstr('4')">
<input type="button" name="z5" value="5" onclick="cstr('5')">
<input type="button" name="z6" value="6" onclick="cstr('6')">
<input type="button" name="l2" value="-" onclick="cstr('-')">
<br>
<input type="button" name="z7" value="7" onclick="cstr('7')">
<input type="button" name="z8" value="8" onclick="cstr('8')">
<input type="button" name="z9" value="9" onclick="cstr('9')">
<input type="button" name="l3" value="*" onclick="cstr('*')">
<br>
<input type="button" name="z0" value="0" onclick="cstr('0')">
<input type="button" name="dg" value="." onclick="cstr('.')">
<input type="button" name="c" value="c" onclick="cstr('c')">
<input type="button" name="l4" value="/" onclick="cstr('/')">
<br>
<input type="button" name="h1" value=" = " onclick="cstr('=')">
</form>
</center>
<body>
</html>