<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>

arrow
arrow
    全站熱搜
    創作者介紹

    harry123168 發表在 痞客邦 留言(0) 人氣()