|
Тема |
Re: Изтегляне на жребий [re: Дackaлa] |
|
Автор | kaпитaнчo (Нерегистриран) | |
Публикувано | 08.12.05 13:06 |
|
|
Ето ти решение. Направи си html файл и сложи това вътре:
<html>
<head>
<script>
var stopped = false;
var interval = 10;
function $(a) { return document.getElementById (a); }
function chop() {
if (stopped) return;
var items = $('participants').value.split ("\n");
$('chosen').value = items[parseInt (Math.random()*items.length)];
setTimeout ('chop()', interval);
}
function start() {
stopped = false;
setTimeout ('chop()', interval);
}
function stop() {
stopped = true;
}
</script>
</head>
<body>
Enter participants - one on each row:<br/>
<textarea rows="20" id="participants"></textarea><br/>
<input type="button" value="Start" onclick="start()" />
<input type="button" value="Stop" onclick="stop()" /><br/>
And the winner is:<br/>
<input type="text" id="chosen" value="" />
</body>
</html>
|
| |
|
|
|