Aleks
asked on
Vbscript to generate random 4 digit code
I have an ASP/VBscript page. I need to assing a randome 4 digit passcode to a hidden field element. I need a function for that is my guess. Can someone help with this ? and what is the value i should give to the hidden element.
Thanks !
A
Thanks !
A
Assuming it can be anything in the range 0000-9999...
TheCode = Right("000" & Int(Rnd * 10000), 4)
TheCode = Right("000" & Int(Rnd * 10000), 4)
ASKER
I found this one;
<script type="text/vbscript">
Dim max,min
max=100
min=1
Randomize
document.write(Int((max-mi n+1)*Rnd+m in))
</script>
If I need 4 numbers I could use:
<script type="text/vbscript">
Dim max,min
max=9999
min=1000
Randomize
document.write(Int((max-mi n+1)*Rnd+m in))
</script>
That way it needs to have 4 digits, now .. how do I call this function to set the value of the hidden field to the results of the above ?
<script type="text/vbscript">
Dim max,min
max=100
min=1
Randomize
document.write(Int((max-mi
</script>
If I need 4 numbers I could use:
<script type="text/vbscript">
Dim max,min
max=9999
min=1000
Randomize
document.write(Int((max-mi
</script>
That way it needs to have 4 digits, now .. how do I call this function to set the value of the hidden field to the results of the above ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great ! .. thanks a million. I finished my page now .. :)
Excellent, glad that helped, thanks for the points.
~bp
~bp
http://www.w3schools.com/vbscript/func_rnd.asp
~bp