|
-
Jul 4th, 2001, 01:27 AM
#1
Thread Starter
Addicted Member
Generate Random Numbers in JScript
I want to make a random ad generator and I want it to generate a random number, and make someting like a select case in VB and put that html code into the browser
Using:
Visual Studio .Net Enterprise
Visual Basic 6.0 Enterprise
-
Jul 4th, 2001, 01:36 AM
#2
Fanatic Member
Alcohol & calculus don't mix.
Never drink & derive.
-
Jul 4th, 2001, 02:11 AM
#3
Thread Starter
Addicted Member
isnt that just 0 and a 1 randomized?
Using:
Visual Studio .Net Enterprise
Visual Basic 6.0 Enterprise
-
Jul 4th, 2001, 10:17 AM
#4
Fanatic Member
Try this:
function doRandom(){
var intRand = Math.round((Math.random() * 2));
switch(intRand){
case 1:
alert("1");
break;
case 2:
alert("2");
break;
}//end switch
}//end function
Just multiply the upper range of the number that you want. If you want a number from 0 to 6 then use Math.random()*6. You have to round the number because Math.random() returns a number between 0.0 and 1.0 .
Chris
-
Jul 4th, 2001, 10:40 AM
#5
Fanatic Member
Yeah.
x = minimum number;
y = maximum number;
randNum = (x + Math.random() * y)
So, (1 + Math.random() * 100) would generate a number between 1 and 100.
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|