ヘッダ部分
<SCRIPT LANGUAGE="JavaScript">
var i = 0
var n = 0
var m = 0
var s = 0
function slot() {
dispNum1()
dispNum2()
dispNum3()
checkResult()
}
function dispNum1() {
i = i + 1
if(i == 10) {
clearTimeout = timerID1
i = 0
}
else {
document.form1.num1.value = Math.floor(Math.random()*10)
timerID1 = setTimeout("dispNum1()","100")
}
}
function dispNum2() {
n = n + 1
if(n == 15) {
clearTimeout = timerID2
n = 0
}
else {
document.form1.num2.value = Math.floor(Math.random()*10)
timerID2 = setTimeout("dispNum2()","100")
}
}
function dispNum3() {
m = m + 1
if(m == 20) {
clearTimeout = timerID3
m = 0
}
else {
document.form1.num3.value = Math.floor(Math.random()*10)
timerID3 = setTimeout("dispNum3()","100")
}
}
function checkResult() {
s = s + 1
if(s == 21) {
clearTimeout = timerIDout
s = 0
if(document.form1.num1.value == document.form1.num2.value && document.form1.num1.value == document.form1.num3.value) {
if(document.form1.num1.value == "7") {
alert("777 is lucky number.CONGRATURATION!!")
}
else {
alert("congraturation!")
}
}
} else {
timerIDout = setTimeout("checkResult()","100")
}
}
</SCRIPT>
ボディ部分
<FORM NAME="form1">
<INPUT TYPE="text" SIZE="1" NAME="num1">
<INPUT TYPE="text" SIZE="1" NAME="num2">
<INPUT TYPE="text" SIZE="1" NAME="num3">
<INPUT TYPE="button" NAME="exec" VALUE="GO" onClick="slot()">
</FORM>