---
title: "生成7位随机数字的js"
author: "shylhd"
date: "2009-08-25T18:19:07Z"
tags: []
slug: "7-js"
draft: false
lastmod: "2009-08-25T18:19:07Z"
id: 457424
url: "https://shylhd.iteye.com/blog/457424"
---

&lt;script&gt;  
var str="qwertyuiopasdfghjklmnbvcxz1234567890"  
function getRandomNum(lbound, ubound) {  
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);  
}  
var s=str.split("");  
var t="";  
for (var i=0;i&lt;7;i++){  
t+=s\[getRandomNum(1,36)];  
}  
alert(t)  
&lt;/script&gt;