因为每次种子都一样,产生的随机数也就一样,现在用当前的毫秒数当种子取随机数var d = new Date();
x=Math.round(Math.random(d.getMilliseconds())*100)
y=Math.round(Math.random(d.getMilliseconds())*100)
x=Math.round(Math.random(d.getMilliseconds())*100)
y=Math.round(Math.random(d.getMilliseconds())*100)
我在楼的和程序里加了一个alert测试,
if(typeof(test_paper.t_answer[0])=='undefined')
{document.write('<option value="'+(x+y)+'">选项'+j+': '+test_paper.t_answer.value)
alert(x+" "+y) <======
}
发现在alert的时候,x和y的值都是新的,就是巳经改过来的(而且text框里的值也改了),但是确定后,它又回到了上一次的值,目前还不知道原因,提出来让大家研究一下.
还有,楼主:只选择一道题的时候,程序有问题
function f_get_result()
{
var i
var result=0
var temp_x,temp_y
for(i=1;i<=test_sum;i++)
{
if(test_sum == 1) //判断是否只有一道题
{
temp_x=test_paper.t_answer.value
temp_y=test_paper.s_answer.value
}
else
{
temp_x=test_paper.t_answer[i-1].value
temp_y=test_paper.s_answer[i-1].value
}
if(temp_x==temp_y)
{
result=result+1
}
else
{
if(test_sum == 1) //同上
test_paper.t_question.value=test_paper.t_question.value+' :(';
else
test_paper.t_question[i-1].value=test_paper.t_question[i-1].value+' :('}
}
test_paper.t_result.value='你的成绩是:'+Math.round(result/test_sum*100)
var x
x=Math.round(result/test_sum*100)
if (x<60)
test_paper.dd.src="image/cry.gif"
if (x>=60)
test_paper.dd.src="image/smile.gif"
}