彩票随机程序 双色球 超级大乐透

把页面拉到最下方看看吧,呵呵<style type="text/css">input { float:left; } #main { float:left; width:270px; height:210px; } #Left { float:left; height:210px; width:150px; } #Right { float:left; height:120px; width:120px; } #label { clear:both; } #title { clear:both; } #result { clear:both; } .red_number { float:left; height:30px; line-height:30px; text-align:center; width:30px; color:Red; cursor:pointer; } .blue_number { float:left; height:30px; line-height:30px; text-align:center; width:30px; color:Blue; cursor:pointer; } </style> <script type="text/javascript"> var redArray=new Array(); var blueArray=new Array(); var flag=0; Array.prototype.Clone=function() { var arrayClone=new Array(this.length); for(var i=0;i<this.length;i++) { arrayClone[i]=this[i]; } return arrayClone; } function $c(s) { return document.createElement(s); } function $(s) { if(document.getElementById) { return document.getElementById(s); } else { return document.all[s]; } } function selectXFromArray(array,x) { var arrayNew=new Array(); var arrayClone=array.Clone(); var total=arrayClone.length; for(var i=0;i<x;i++) { var index = getRnd(total)-1; arrayNew.push(arrayClone[index]); arrayClone.splice(index,1); total--; } return arrayNew.sort(sortArray); } function sortArray(x,y) { return x-y; } function getRnd(max) { return Math.ceil(Math.random()*max); } function init() { var divMain=$c("DIV"); divMain.id="main"; var divRight=$c("DIV"); divRight.id="Right"; var divLeft=$c("DIV"); var label=$c("DIV"); var divTitle=$c("DIV"); divTitle.id="title"; divTitle.innerHTML="选中结果:"; label.id="label"; divLeft.id="Left"; for(var i=1;i<36;i++) { var divInner=$c("DIV"); divInner.innerHTML=i; divInner.className="red_number"; divInner.onmouseover=function() { this.style.backgroundColor="#ccc"; } divInner.onmouseout=function() { this.style.backgroundColor="#fff"; } divInner.onclick=function() { redArray.push(parseInt(this.innerHTML)); this.onmouseout=""; this.onmouseover=""; label.appendChild(this); } divLeft.appendChild(divInner); } for(var i=1;i<17;i++) { var divInner=$c("DIV"); divInner.innerHTML=i; divInner.className="blue_number"; divInner.onmouseover=function() { this.style.backgroundColor="#ccc"; } divInner.onmouseout=function() { this.style.backgroundColor="#fff"; } divInner.onclick=function() { blueArray.push(parseInt(this.innerHTML)); this.onmouseout=""; this.onmouseover=""; label.appendChild(this); } divRight.appendChild(divInner); } divMain.appendChild(divLeft); divMain.appendChild(divRight); document.body.appendChild(divMain); document.body.appendChild(divTitle); document.body.appendChild(label); document.body.appendChild($c("BR")); document.body.appendChild($c("BR")); document.body.appendChild($c("BR")); var btnTicai=$c("INPUT"); btnTicai.type="button"; btnTicai.value="体彩"; btnTicai.onclick=goTicai; document.body.appendChild(btnTicai); var btnFucai=$c("INPUT"); btnFucai.type="button"; btnFucai.value="福彩"; btnFucai.onclick=goFucai; document.body.appendChild(btnFucai); var divResult=$c("DIV"); divResult.id="result"; document.body.appendChild(divResult); } function goTicai() { red2blue(5,2); } function goFucai() { red2blue(6,1); } function red2blue(r,b) { if(flag>0) { } else{ flag++; if(redArray.length<r) { alert("请选择"+r+"个以上的红球进行随机"); return; } if(blueArray.length<b) { alert("请选择"+b+"个以上的蓝球进行随机"); return; } } var divResult=$("result"); divResult.innerHTML=""; var red=selectXFromArray(redArray,r); for(var i=0;i<red.length;i++) { var divInner=$c("DIV"); divInner.innerHTML=red[i]; divInner.className="red_number"; divResult.appendChild(divInner); } var blue=selectXFromArray(blueArray,b); for(var i=0;i<blue.length;i++) { var divInner=$c("DIV"); divInner.innerHTML=blue[i]; divInner.className="blue_number"; divResult.appendChild(divInner); } } window.onload=init; </script>

你可能感兴趣的:(程序)