已经有这么一段随机序列号生成代码,
<script language=vbs>
function getRnd(min,max,num)
Dim myarr(),i,j
if num> max-min+1 or num <0 then
getRnd= "Error:num> max-min "
exit function
end if
redim myarr(num-1)
i=0
while i <num
Randomize
no = Int((max-min+1)*Rnd+min)
For j = 0 To i-1
If no = myarr(j) Then Exit For
Next
if j=i then
myarr(i) = no
i=i+1
End if
wend
getRnd=join(myarr, ", ")
end function
for i=1 to 100
document.write getRnd(10000000,900000000,1)& " <br> "
next
</script>
执行的时候显示的是100对随机数字,我想放置一个按钮,每点一下按钮生成一个数字,请问我该怎么写呢?
<form id= "form1 " name= "form1 " method= "post " action= " " >
<input type= "submit " name= "Submit " value= "生成随机序列号 " >
</form>
多谢大虾指点!
------解决方案--------------------
<script language=vbs>
function getRnd(min,max,num)
Dim myarr(),i,j
if num> max-min+1 or num <0 then
getRnd= "Error:num> max-min "
exit function
end if
redim myarr(num-1)
i=0
while i <num
Randomize
no = Int((max-min+1)*Rnd+min)
For j = 0 To i-1
If no = myarr(j) Then Exit For
Next
if j=i then
myarr(i) = no
i=i+1
End if
wend
getRnd=join(myarr, ", ")
end function
sub Submit_onclick
for i=1 to 100
document.write getRnd(10000000,900000000,1)& " <br> "
next
end sub
</script>
<input type= "button " name= "Submit " value= "生成随机序列号 ">