作者m81632 (Dr.Lee)
看板Ajax
标题[问题] 看不到数字
时间Tue Jun 26 22:46:58 2007
下面的程式可以执行
不过一开却看不到数字
可以帮看一下哪里有错吗
因为应该是一开始就有数字了
不过却看不到
谢谢
<html>
<head>
<meta http-equiv="Content-Language" content="zh-tw">
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>动动脑时间</title>
</head>
<script language="javascript">
<!--
var x=0;
var y=0;
var z=0;
var w=0;
var count=0;
var correct=0;
function generQQ(){
//随机产生整数
x=parseInt(Math.random()*19)+1;
y=parseInt(Math.random()*9)+1;
z=parseInt(Math.random()*9)+1;
w=parseInt(Math.random()*19)+1;
//将产生的值指定给T1和T2和T3和T4
document.myform.T1.value=x;
document.myform.T2.value=y;
document.myform.T3.value=z;
document.myform.T4.value=w;
//T5一开始设定为空白,并取得焦点
document.myform.T5.value="";
document.myform.T5.focus();
//将ans1, ans2都设为隐藏
document.all.A1.style.visibility="hidden";
document.all.A2.style.visibility="hidden";
count +=1;
}
function checkAns(){
var ans= document.myform.T5.value;
//是否按下Enter键
if(event.keyCode==13)
{
//答案是否正确
if(x+y*z-w == ans){
correct += 1;
A1.style.visibility="visible";
alert("目前答对比例:" + correct + "/" + count);
}else{
A2.style.visibility="visible";
}
}
}
//-->
</script>
<body>
<form name="myform" action="--WEBBOT-SELF--" method="POST">
<!--webbot bot="SaveResults" U-File="C:\Documents and Settings\Administrator\桌面\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p>动动脑时间 :
<input type="button" value="下一题" name="B1" onclick="generQQ()"></p>
<p>
<input type="text" name="T1" size="10">+
<input type="text" name="T2" size="10">*
<input type="text" name="T3" size="10">-
<input type="text" name="T4" size="10">=
<input type="text" name="T5" size="20" onkeydown="checkAns();"></p>
</form>
<div id="A1" style="position:absolute; top:110px; left:146px; width:75px; height:20px; color:blue; visibility:hidden" >
答对了!
</div>
<div id="A2" style="position:absolute; top:110px; left:146px; width:75px; height:20px; color:red; visibility:hidden " >
答错了!
</div>
</body>
</html>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.127.186.4
※ 编辑: m81632 来自: 140.127.186.4 (06/26 22:53)