小弟幫公司設計了一個抽獎程式,為顧及畫面的美觀,加入了一個動態畫面的程式進去(以vbscript搭配asp),
其程式流程大致如下 : 主程式抽出若干組中獎號碼後, 將這幾組中獎號碼傳入此一動態畫面程式之中,將三組中獎號碼設為全域變數 : pp0, pp1, pp2, 以及一個xb變數用來確定目前該取出哪一組中獎號碼,
function runtime()之中, 利用迴圈去執行另一個function runtime1(),在runtime1()之中會依迴圈,依序取出pp0~pp2之中獎號碼, 每取出一組號碼, 則將該組號碼之數字拆開成五個碼(萬位數補0),做滾動式之動態畫面(類似水果盤bar之效果), 然後定時會滾出原來之數字,再顯示在下方.....
但小弟測試之結果 :
1.每次去抓號碼時, 三組抓出來之號碼都是最後一組(pp2 : 7892), 若中獎號碼有10組, 則抓出的10組號碼皆為最後一組之號碼 , 若將function runtime1(),寫成三個不同名稱之function, 其結果還是一樣!
2.滾動完之號碼的個位數, 常會與原來的號碼之個位數不同....
3.時間bar可否維持固定在同一行, 而不是每抽一組號碼, 就多跑出一行
PS : 因要讓各位高手容易看程式,所以只預設三組中獎號碼,實際上在抽獎進行時,最多會同時抽400組號碼!
是否可以向各位vbscript的高手們求救,因為過幾天就要上線使用了!!
在此先向各位程式高手達人致上最誠摯的感謝!! 以下是小弟所寫的程式 ( 副檔名為.asp ) :
<html>
<head><title>test</title></head>
<SCRIPT language="VBScript">
Dim xb
pp0= "1235" '--取得得獎號碼
pp1= "2341" '--取得得獎號碼
pp2= "7892" '--取得得獎號碼
function runtime()
dim t
dim tt
dim mm,ss
on error resume next
t=cint(document.thisform.clock.value)-1
mm=cstr(fix(cint(document.thisform.clock.value)/60))
ss=cstr(cint(document.thisform.clock.value)/60)
document.thisform.clock.value=cstr(t)
for a=1 to 3
xb = a
runtime1()
next
end function
function runtime1()
dim t
dim tt
dim mm,ss
on error resume next
t=cint(document.thisform.clock.value)-1
mm=cstr(fix(cint(document.thisform.clock.value)/60))
ss=cstr(cint(document.thisform.clock.value)/60)
document.thisform.clock.value=cstr(t)
id=settimeout("runtime1()",30)
'''pp= <%=cstr(request("x"))%> '--取得得獎號碼
if xb= 1 then
pp = pp0
end if
if xb = 2 then
pp = pp1
end if
if xb = 3 then
pp = pp2
end if
pn= document.thisform.pnn.value '--取得抽獎名稱
pi= document.thisform.pii.value '--取得抽獎項目
px= len(pp) '--得獎號碼字串長度
pp= string(5-px,"0")&pp '--字串長度補足5位
px= len(pp)
redim p(px)
for a=1 to px
p(a)= mid(pp,a,1) '--將得獎號碼拆開放置於 array
next
''if t=488 then msgbox pp
''if t=488 then msgbox p(1)
''if t=488 then msgbox p(2)
''if t=488 then msgbox p(3)
''if t=488 then msgbox p(4)
''if t=488 then msgbox p(5)
if t=1 then
NowD.InnerHtml = p(1) & p(2) & p(3) & p(4) & p(5) '--當 t=0 時, show 號碼的個位數字
end if
'-------------------------------------------------------------------------------------------------
if t=1 then
NowA.InnerHtml = p(5) '--當 t=0 時, show 號碼的個位數字
else
NowA.InnerHtml = right(cstr(t+cint(p(5)) mod 10),1) '--t>0 時, show 滾動個位數字
end if
if t>100 then
NowB.InnerHtml = right(cstr(t+cint(p(4)) mod 10),1)
else
NowB.InnerHtml = p(4)
end if
if t>200 then
NowC.InnerHtml = right(cstr(t+cint(p(3)) mod 10),1)
else
NowC.InnerHtml = p(3)
end if
if t>300 then
NowY.InnerHtml = right(cstr(t+cint(p(2)) mod 10),1)
else
NowY.InnerHtml = p(2)
end if
if t>400 then
NowZ.InnerHtml = right(cstr(1+t+cint(p(1)) mod 10),1)
else
NowZ.InnerHtml = p(1)
if trim(NowZ.InnerHtml)="" then NowZ.InnerHtml="0"
end if
'--Timer
NowTime = Cstr(time)
NowT.InnerHtml = NowTime
'document.write NowTime
if (t mod 20)=0 then
NowX.InnerHtml= NowX.InnerHtml & "█"
end if
'--時間到, 轉值(址)回結果網頁
if t=0 then
cleartimeout id
''msgbox "開獎完成 !!"
'''location.replace("wpz_001.asp?pn="& pn &"&pi="& pi &"&passX="& pp &"&passYN=99")
for a=1 to 5000000
next
document.thisform.clock.value=450
end if
end function
</SCRIPT>
<body onload="runtime()">
<form name="thisform">
倒數單位 : <input type="text" name="clock" value=450>
<!--input type="button" value="時 間" onclick="runtime()"-->
<input type="hidden" value=<%=request("pn")%> name=pnn>
<input type="hidden" value=<%=request("pi")%> name=pii>
</form>
<%
''response.write request("x")
''response.write "<br>"
'' pp= request("x")
''response.write "<br>"
'' px= len(pp)
'' redim p(px)
'' for a=1 to px
'' p(a)= mid(pp,a,1)
'' response.write p(a)
'' next
'' response.write "<br>"
''response.write request("pn")
''response.write "<br>"
''response.write request("pi")
%>
<br>
<table align=center border=1>
<tr>
<td ><font size=7 color=green><b id="NowT"></font></td>
</tr>
</table>
<br>
<table align=center border=1>
<tr>
<td colspan=5><font size=7 color=blue>得獎號碼</font></td>
</tr>
<tr>
<td align=center><font size=8 color=red><b id="NowZ"></font></td>
<td align=center><font size=8 color=red><b id="NowY"></font></td>
<td align=center><font size=8 color=red><b id="NowC"></font></td>
<td align=center><font size=8 color=red><b id="NowB"></font></td>
<td align=center><font size=8 color=red><b id="NowA"></font></td>
</tr>
</table>
<br>
<table align=center >
<tr>
<td><font size=7><b id="NowH"></font></td>
<td><font size=7><b id="NowG"></font></td>
<td><font size=7><b id="NowF"></font></td>
<td><font size=7><b id="NowE"></font></td>
<td><font size=7><b id="NowD"></font></td>
</tr>
</table>
<table align=center border=1 width=402>
<tr>
<td ><font size=3 color=orange><b id="NowX"></font></td>
</tr>
</table>
</body>
</html>