23,404
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>双色球号码生成</title>
</head>
<body>
<script type="text/javascript" language="javascript">
function startup(){
document.getElementById("startup").style.visibility = "hidden";
var nums = new Array(6);
for(var i = 0;i<6;){
var red = rand(1,32);var hasExist = false;
for(var j = 0;j<=i; j++){if(nums[j] - red == 0){ hasExist = true;break;} }
if(hasExist){continue;}else{ nums[i] = red; i++;}
}
nums.sort(sortFun);
document.getElementById("resultRed").value = nums;
document.getElementById("resultBlue").value = rand(1,16);
document.getElementById("startup").style.visibility = "visible";
}
function rand(m,n){ return Math.floor( Math.random() * n - m + 1 ) + m ; }
function sortFun(a,b){ return a-b;}
</script>
<input type="button" id="startup" onclick="startup();" value="Start"/>
<input type="text" id="resultRed" style="color:#F00; font-weight:600; width:150px;"/>
<input type="text" id="resultBlue" style="color:#00F; font-weight:600; width:30px;"/>
</body>
</html>