<scripttype="text/javascript">var i = 0;
//t用來接收setTimeOut()的返回值var t;
var st = ['張三','李四', '老王','旺財','鐵柱', '王八','來福','小明','小紅','狗蛋','SB.Child'];
var u;
//點名函數functionstudents()
{//順序點名/* if (i < st.length)
{
u = st[i];
}
else
{
//點到最後一個就回來重新點起
i = 0;
u = st[i];
}
i = i + 1;
*///隨機點名 產生0-數組長度之間的數作爲數組下標var num = Math.floor(Math.random()*st.length);
u = st[num];
//更改文本框顯示的value值
document.getElementById("div1").innerHTML = u ;
t = setTimeout("students()", 1000);
}
//停止點名函數functionstop()
{
clearTimeout(t);
}
</script>