close

<html>
<script>
var rx;

function radom()
{
 
  rx="";
  var a1 = Math.floor(Math.random()*10);
  var a2 = Math.floor(Math.random()*10);
  var a3 = Math.floor(Math.random()*10);


  while(a2==a1)
  
  a2 = Math.floor(Math.random()*10);
  
  while((a3==a1)||(a3==a2))
  
  a3 = Math.floor(Math.random()*10);

  rx = a1+""+a2+""+a3;
  document.write(rx);
 
}
   </script>
<body>
 <input type="button" value="亂數" onclick="radom()"/>
</body>
將上述程式碼貼在文件檔改檔名為.html

擷取.PNG

案亂數按鈕後變為

擷取2.PNG

 

arrow
arrow
    全站熱搜

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