私人领地

js随机生成N位数

function RondomPass(number){
    var arr = new Array;
    var arr1 = new Array("0","1","2","3","4","5","6","7","8","9");
    
    for(var i=0;i<number;i++){
        var n = Math.floor(Math.random()*10);
        arr[i] =arr1[n] ;
        //document.write(arr1[n]);    
    }
    
    val = arr.join("")
    //document.write(val);
    return val;    
    
}
RondomPass(8

适用于 随机生成密码

posted @ 2014-05-24 17:58  狂奔的蜗牛Snails  阅读(1995)  评论(0编辑  收藏  举报