因为每次种子都一样,产生的随机数也就一样,现在用当前的毫秒数当种子取随机数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)
解决方案 »
- 关于数据更新语句
- 在《JavaScript语言精粹》一书中对于下面这段话不理解
- 怎么样为从数据库中的内容自动生成HTML页面
- Javascript动态创建表行及控件,并循环行及列取出用户提交的输入值。(参考知网搜索)
- 请教一个函数写法的小问题!
- 各位大哥,如何在打开窗口时,把窗口的关闭按钮屏蔽,保留最大,最小化按钮?
- 用的VBScript 。 做发信的时候出错。 内有详细代码。 谁能指出原因 ??? 多谢多谢
- javascript病毒爱好者请进。
- 怎樣從Array中任意徹底刪除其中一行數據
- 有关表格变颜色的问题!!!!在线等待.....
- 请问大家怎么样隐藏表格的一行呀,谢谢
- 我叙述不清楚,请高手进来看看我的代码和问题吧!!!急
我在楼的和程序里加了一个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"
}