<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>第一支javaScript</title>
</head>
<body>
<h2>document.write用法</h2>
<Script type ="text/javascript">
function add() {
var a,b,c,maxNum,minNum;
maxNum = 9;
minNum = 0;
a= Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
do{
var exist = true;
b= Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
if(b != a) exist = false;
}while (exist);
do{
var exist = true;
c= Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
if(c != b && c != a) exist = false;
}while (exist);
document.getElementById('c3').value ="亂數"+a+b+c;
}
</Script>
<input type="text" name="address" id="c3" <br></br>
<input type="button" value="產生亂數" onclick="add()"/>
</body>
</html>
- Jun 03 Fri 2016 15:21
JAVA2016.6.3
全站熱搜
留言列表