Re: [問題]新手 javascript的問題

看板Web_Design作者 (根暗で陰湿?大きなお世話)時間19年前 (2005/10/27 17:31), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html> <head> <title>樂透測試</title> </head> <body> <script type="text/javascript"> var text1 = document.getElementById("text1"); function RandomInt( low, high ) { return Math.floor(Math.random()*(high-low+1)) + low; } function lottery() { var i; var pocket = []; text1.value = ""; for(i = 0; i < 42; ++i) pocket.push(i); var hand = []; for(i = 0; i < 6; ++i) { var choose = Randint(0, pocket.length); hand.push(pocket[choose]); pocket[choose] = pocket[pocket.length - 1]; pocket.pop(); } text1.innerHTML = hand[0]; for(i = 1; i < hand.langth; ++i) { text1.innerHTML += ', ' + hand[i]; } } </script> <div><span id="text1"></span><a href="javascript: lottery()">選號</a></div> </body> </html> -- ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ - ██◤ ◥█◤ ██◣ ██◣ ██◤ ◢██ -▅▃ █ █ █ █▄▄ █ █ █ ◣ ◢ / - █ ██◢█ ▄▄▌ █ █ ◤ ◥ ◢█◣ █ ◣ ██◤ █ ██◤ ▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ Mozilla Firefox -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.122.126.43
文章代碼(AID): #13O9vvcM (Web_Design)
文章代碼(AID): #13O9vvcM (Web_Design)