HighDots Forums  

Re: Help Please with Button Actions - JavaScript

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Help Please with Button Actions - JavaScript in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Evertjan.
 
Posts: n/a

Default Re: Help Please with Button Actions - JavaScript - 05-05-2004 , 02:26 PM






TrvlOrm wrote on 05 mei 2004 in comp.lang.javascript:

Quote:
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")
}
}
}

Commenting only on this function
[M in Math should be capitalized both times !!!!]

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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
  #2  
Old   
Dr John Stockton
 
Posts: n/a

Default Re: Help Please with Button Actions - JavaScript - 05-06-2004 , 11:56 AM






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 :
Quote:
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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.


Reply With Quote
  #3  
Old   
TrvlOrm
 
Posts: n/a

Default Ok Thanks - 05-06-2004 , 06:48 PM



Thank you so much for all the help on this. With a bit of playing
around, I finally got it to work.

Thanks again.

Dr John Stockton <spam (AT) merlyn (DOT) demon.co.uk> wrote

Quote:
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.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.