DiLDoG
01-07-2003, 11:38 AM
How do I generate a random char?
(a-z,A-Z,0-9)
(a-z,A-Z,0-9)
|
Click to See Complete Forum and Search --> : Random char DiLDoG 01-07-2003, 11:38 AM How do I generate a random char? (a-z,A-Z,0-9) BestZest 01-07-2003, 11:46 AM The way I'd do it would be to create an Array with all the characters then pick a random number and get that index. chars=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9") function pickChar() { ran=Math.floor((Math.random()*chars.length)) char=chars[ran] } The code picks a random number, then get the character at that point. The character is 'char' BestZest webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |