js 字母+数字随机数获取
<html> <head> <title></title> <meta content="charset=utf-8" /> </head> <body> 每条字母数: <input type="text" id="engNum" /> <br /> 每条数字数: <input type="text" id="num" /> <br /> 获取条数: <input type="text" id="ranNum" /> <br /> <input type="button" onclick="getRan()" value="获取" /> <br /> <div id="res"></div> <script> var chars = ['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']; function getEng(n) { var res = ""; for (var i = 0; i < n; i++) { var id = Math.ceil(Math.random() * 51); res += chars[id]; } return res; } function RndNum(n) { var rnd = ""; for (var i = 0; i < n; i++) { rnd += Math.floor(Math.random() * 10); } return rnd; } function getRan() { var ran = ""; var engNum = document.getElementById("engNum").value; var num = document.getElementById("num").value; var ranNum = document.getElementById("ranNum").value; document.getElementById("res").innerHTML = ""; for (var i = 0; i < ranNum; i++) { ran = getEng(engNum) + RndNum(num); document.getElementById("res").innerHTML += ran + "<br/>"; } } </script> </body> </html>