<html>
<head>
<script>
function randomTest(){
var numList = [];
for(var i=1;i<=33;i++){
numList[i-1] = i;
}
for(var i=1;i<=7;i++){
var num = Math.floor(Math.random() * (numList.length-(i-1)));
document.getElementById('jx'+i).value=numList[num];
numList[num] = numList[numList.length-1-(i-1)];
}
}
</script>
</head>
<body>
<input type="text" id="jx1"/>
<input type="text" id="jx2"/>
<input type="text" id="jx3"/>
<input type="text" id="jx4"/>
<input type="text" id="jx5"/>
<input type="text" id="jx6"/>
<input type="text" id="jx7"/>
<input type="button"value="機選一注雙色球" onclick="randomTest()"/>
</body>
</html>
這個我寫的 就是第七個 不知道怎麼弄才不超過16 有沒有什麼辦法 求指教
哎,
<html>
<head>
<script>
function randomTest(){
var numList = [];
var blueNumList=[];
for(var i=1;i<=33;i++){
numList[i-1] = i;
}
for(var i=1;i<=16;i++){
blueNumList[i-1] = i;
}
for(var i=1;i<=6;i++){
var num = Math.floor(Math.random() * (numList.length-(i-1)));
document.getElementById('jx'+i).value=numList[num];
numList[num] = numList[numList.length-1-(i-1)];
}
var num2 = Math.floor(Math.random() * (blueNumList.length-(i-1)));
document.getElementById('jx7').value=blueNumList[num2];
}
</script>
</head>
<body>
<input type="text" id="jx1"/>
<input type="text" id="jx2"/>
<input type="text" id="jx3"/>
<input type="text" id="jx4"/>
<input type="text" id="jx5"/>
<input type="text" id="jx6"/>
<input type="text" id="jx7"/>
<input type="button"value="機選一注雙色球" onclick="randomTest()"/>
</body>
</html>