![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
function DrawNumbers( ) { for (var x=1; x<7;x++) { var num = Math.round(math.random( )*100; switch (x) { case 1: document.frmNumbers.txtnum1.value = num; break case 2: document.frmNumbers.txtnum2.value = num; break case 3: document.frmNumbers.txtnum3.value = num; break case 4: document.frmNumbers.txtnum4.value = num; break case 5: document.frmNumbers.txtnum5.value = num; break case 6: document.frmNumbers.txtnum6.value = num; break default: alert("x doesn't match") } } } |
#2
| |||
| |||
|
|
function DrawNumbers( ){ for (var x=1; x<7;x++) { document.frmNumbers["txtnum"+x].value = Math.round(Math.random()*100; } } This should do the same not tested |
#3
| |||
| |||
|
|
JRS: In article <Xns94E0CFF6C2918eejj99 (AT) 194 (DOT) 109.133.29>, seen in news:comp.lang.javascript, Evertjan. <exjxw.hannivoort (AT) interxnl (DOT) net posted at Wed, 5 May 2004 18:26:36 : function DrawNumbers( ){ for (var x=1; x<7;x++) { document.frmNumbers["txtnum"+x].value = Math.round(Math.random()*100; } } This should do the same not tested I would have suggested something similar, though probably using function Random (see FAQ 4.22, as you know). BTW, that function has neither the missing ) nor the wrong Method of Math. But the OP wishes for a Draw, and the essence of a Draw is that numbers cannot repeat. The chance of a repeat above must exceed 10%, at a guess. A Draw is in essence a partial Deal, and if the FAQ is searched for that, sec. 4.22 will be found, with a suitable Link. |
![]() |
| Thread Tools | |
| Display Modes | |
| |