相思资源网 Design By www.200059.com
JS代码:
function s20(){ var data=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]; for(var j=0;j<500;j++){ //500为想要产生的行数 var result=""; for(var i=0;i<20;i++){ //产生20位就使i<20 r=Math.floor(Math.random()*16); //16为数组里面数据的数量,目的是以此当下标取数组data里的值! result+=data[r]; //输出20次随机数的同时,让rrr加20次,就是20位的随机字符串了。 } document.write(result); document.write("<br/>"); } }
完整html代码:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript"> function s20(){ var data=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]; for(var j=0;j<500;j++){ var result=""; for(var i=0;i<20;i++){ r=Math.floor(Math.random()*16); result+=data[r]; } document.write(result); document.write("<br/>"); } } </script> </head> <body> <input type="button" onclick="s20()" value="产生随机数"> </body> </html>
标签:
随机数
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无JS中产生20位随机数以0-9为例也可以是a-z A-Z的评论...