码迷,mamicode.com
首页 > Web开发 > 详细

js生成邀请码

时间:2017-03-31 13:37:09      阅读:345      评论:0      收藏:0      [点我收藏+]

标签:html   substr   type   code   sub   lan   doc   tle   body   

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
	</head>	
	<script>		
function uuid() {
    var s = [];
    var hexDigits = "0123456789abcdefghijklmnopq";
    for (var i = 0; i < 6; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }    
   var uuid = s.join("");
    document.getElementById("ic").value=uuid;
}
function MathRand() 
{ 
var Num=""; 
for(var i=0;i<6;i++) 
{ 
Num+=Math.floor(Math.random()*10); 
} 
document.getElementById("ic").value=Num; 
}
function createInviteCode() {
		var randomChar = Math.random().toString(16).substr(9);		
		document.getElementById("ic").value=randomChar;
}
	</script>
	<body>
    <div>
		<input id="ic" type="text"/>
		<input id="yqmYqm" class="yqm" type="button" value="生成邀请码1" onclick="MathRand()"/>	
		<input id="yqmYqm" class="yqm" type="button" value="生成邀请码2" onclick="uuid()"/>	
		<input id="yqmYqm" class="yqm" type="button" value="生成邀请码3" onclick="createInviteCode()"/>	
	</div>	
	</body>
</html>

  

js生成邀请码

标签:html   substr   type   code   sub   lan   doc   tle   body   

原文地址:http://www.cnblogs.com/ipetergo/p/6650554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!