<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>亂數不重複</title>
<h2>亂數不重複</h2>
<Script type ="text/javascript">
function add() {
var a=0,b=0,c=0;
var minNum = 0;
var maxNum = 9;
a = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
b = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
c = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
while(b==a)
{b = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;}
while(c==a )
{c = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;}
while(c==b )
{c = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;}
document.getElementById('c3').value ="亂數:"+a+b+c;
}
</Script>
<input type="text" name="address" id="c3" <br></br>
<input type="button" value="Random" onclick="add()"/>
</head>
<body>
</body>
</html>