1.HTML
<body><div id="content"><div id = "top"><div id = "username">用户号码:</div><div id = "qiu"><span id = "red">红球:</span><input id = "redqiu1"/><input id = "redqiu2"/><input id = "redqiu3"/><input id = "redqiu4"/><input id = "redqiu5"/><input id = "redqiu6"/><span id = "blue">蓝球:</span><input id = "blueqiu7"/></div></div><div id = "center"><div id = "zjname">中奖号码:</div><div id = "qiu1"><span id = "red1">红球:</span><div class="redqiu" id = "red01"></div><div class="redqiu" id = "red02"></div><div class="redqiu" id = "red03"></div><div class="redqiu" id = "red04"></div><div class="redqiu" id = "red05"></div><div class="redqiu" id = "red06"></div><span id = "blue01">蓝球:</span><div id = "blueqiu01"></div></div></div><div id = "bottom"><div id ="outcome">结果为:</div><div id="kai">开奖</div></div></div></body>
2.JS
<script type="text/javascript">var nums= [];var b = 0;var usernums = [];var o = [];var l = 1;// var zjnum =[];function isSave(nums,len,tag){for(var i = 0;i < len;i++){if(nums[i] == tag){return 1;}}return 0;}// function print( nums,len)// {// for(int i = 0;i < len;i++)// {// cout << nums[i] << ",";// }// cout << endl;// }function zjnums(){for(var i = 0;i<7;i++){if(i != 6){var x = Math.random()*33+1;x = Math.floor(x);var t = isSave(nums,6,x);if(t){i--;continue;}else{// $("#redqiu").html(x);nums[i] = x;}}else{var y = Math.random()*16+1;y = Math.floor(y);// $("#blueqiu01").html(y);nums[6] = y;}$("#redqiu").html("机选的号码为"+ ":" + nums);}}function xz(s,w){if(w == 6){if(s<0 || s >16){$("#outcome").html("号码有误");return 0;}else{usernums[w] = s;return 1;}}else{if(s<0 || s > 33){$("#outcome").html("号码有误");return 0;}else{usernums[w] = s;return 1;}}}function getusernums(){o[0] = xz($("#redqiu1").val(),0);o[1] = xz($("#redqiu2").val(),1);o[2] = xz($("#redqiu3").val(),2);o[3] = xz($("#redqiu4").val(),3);o[4] = xz($("#redqiu5").val(),4);o[5] = xz($("#redqiu6").val(),5);o[6] = xz($("#blueqiu7").val(),6);}function timezjnum(){var x = Math.random()*33+1;x = Math.floor(x);var y = Math.random()*16+1;y = Math.floor(y);if(b<20){$("#red01").html(x);}else if(b ==20){$("#red01").html(nums[0]);}else if(b < 40){$("#red02").html(x);}else if(b == 40){$("#red02").html(nums[1])}else if(b<60){$("#red03").html(x);}else if(b == 60){$("#red03").html(nums[2])}else if(b<80){$("#red04").html(x);}else if(b == 80){$("#red04").html(nums[3])}else if(b<100){$("#red05").html(x);}else if(b == 100){$("#red05").html(nums[4])}else if(b<120){$("#red06").html(x);}else if(b == 120){$("#red06").html(nums[5])}else if(b<140){$("#blueqiu01").html(y);}else if(b == 140){$("#blueqiu01").html(nums[6])}else{b=0;clearInterval(id);zhong();console.log(nums);console.log(usernums);}b++;}function zhong(){var x = 0;for (var i = 0; i < 7; i++) {for(var j = 0;j<7;j++){if(nums[i] == usernums[j]){x++;$("#zjname").html(zjnums[i]); }}}switch(x){case 3:$("#outcome").html("5元");break;case 4:$("#outcome").html("50元");break;case 5:$("#outcome").html("500元");break;case 6:$("#outcome").html("50000元");break;case 7:$("#outcome").html("20000000元");break;default:$("#outcome").html("谢谢惠顾");break;}}$("#kai").click(function(){nums= [];b = 0;usernums = [];o = [];l = 1;getusernums();for(var i = 0; i < 7; i++){if(o[i] == 0){l = 0;} }if(l){id = setInterval(timezjnum,80);zjnums();}});</script>
效果展示:

