灵饰固伤加多少:我想用ASP来随机出题

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/30 02:04:02
我想用ASP来随机出题,两个20以内的整数相加,得数由学习者输入,再按"交卷"按钮提交.如果输入正确,显示√号;如果不对,就显示×号,并同时显示正确结果.学习者再按一下"出题",又可继续做下一道随机数学题.
我已经做了一些,但不能如愿完成,请名位高手指点指点.谢谢!!!
<script language="javascript">
a=Math.round(Math.random()*20)
b=Math.round(Math.random()*20)
document.write(a)
document.write("+")
document.write(b)
document.write("=")
</script>
<form name="form1" method="post" action="">
 <input name="textfield" type="text" size="8" maxlength="8">
<input type="submit" name="Submit" value="交卷">
 <input type="submit" name="Submit2" value="出题">
</form>

<script language="javascript">
function gettm(){
x = Math.round(Math.random()*20)
y = Math.round(Math.random()*20)
s1.innerHTML = (x + "+" + y + "=")
form1.da.value = (x + y)
}
function checktm(){
if(form1.ds.value==form1.da.value){
s1.innerHTML = s1.innerHTML + (form1.da.value + " <font color='#FF0000'>√</font>")
}else{
s1.innerHTML = s1.innerHTML + (" <font color='#FF0000'>×</font> 正确答案为:"+form1.da.value)
}
}
</script>
<span name="s1" id="s1"></span><br>
<form name="form1" method="post" action="">
<input name="ds" type="text" id="ds" size="8" maxlength="8">
<input type="button" name="jj" value="交卷" onClick="checktm();">
<input type="button" name="ct" value="出题" onClick="gettm();">
<input name="da" type="hidden" value="0">
</form>