473,715 Members | 5,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random Number Blues

Using MSIE 5+ Heath writes:

My problem deals with working with window objects between
pages as follows:

My Introduction page contains a link to my Action page.
The onClick of that link creates a series of random numbers
that are appended to the end of the url of the Action page.
After initiating the link the URL of the Action page
looks like this:

http://Action.htm?61,65,24,22 etc x 16.

Now a user chooses two of those numbers, say 61 and 24,
from the Action page and they are sent to a Pop-Up page.

On the Pop-up page the user has to choose between
the two numbers, say he or she chooses 61.

**How do I get that number, 61, back to the Action page?**

The problem I am having is that I don't know how
to set the Action page as an object, because of adding
the random numbers on the end it makes it tuff.

Normally I would create an object like

var ActionPage = window.open("Ac tion.htm", "Action"),

but that won't work because of the random Numbers.

I had to send them from the Introduction page, therefore
the Action page object I created on the Introduction page
is wiped out when the Action page JavaScript loads.

I also can't send anything back to the Action page's URL
because I need it to stay how it is for the random numbers.

Final Notes: I don't know CGI so I can't use it yet. Although
it is bad form, this page is completely dependent on JavaScript
otherwise I would have to write 4000 pages, which won't work.
Jul 20 '05 #1
3 2679
Lee
hj******@email. com said:

Using MSIE 5+ Heath writes:

My problem deals with working with window objects between
pages as follows:
Your Subject line was poorly chosen, since it gives the
impression that you are having trouble with the Math.random()
method.
My Introduction page contains a link to my Action page.
The onClick of that link creates a series of random numbers
that are appended to the end of the url of the Action page.
After initiating the link the URL of the Action page
looks like this:

http://Action.htm?61,65,24,22 etc x 16.

Now a user chooses two of those numbers, say 61 and 24,
from the Action page and they are sent to a Pop-Up page.
Is the "Pop-Up page" opening in a new window, as the name
seems to imply (we've already been fooled once)? If so,
that Window can refer back to the Action page via it's
"opener" attribute.
On the Pop-up page the user has to choose between
the two numbers, say he or she chooses 61.

**How do I get that number, 61, back to the Action page?**
Normally I would create an object like

var ActionPage = window.open("Ac tion.htm", "Action"),

but that won't work because of the random Numbers.


I don't see how it will help, but you can use variables
in the window.open() call, or you can create the URL as
a variable:

var sep="?";
var URL="Action.htm ";
for(var i=0;i<16;i++){
URL+=sep+Math.f loor(Math.rando m()*100);
sep=",";
}
var ActionPage=wind ow.open(URL,"Ac tion");

Jul 20 '05 #2
This is exactly what I tried (using the var x = window.open(),
but it just creates a eternal loop. Because the random
numbers can only be generate once, at the beginning, per
user session.

The basic flow is:
random numbers = R

Intro >> 64R >> Action
User chooses two numbers
Action >> 2R >> Pop-up (external window)
User chooses one of the two numbers
Pop-up >> 1R >> Action

The problem is I assign var Action = window.open("Ac tion.htm")
in the Intro page, but when "Action.htm " loads it has a .js file
attached to it so the Intro .js is wiped out.

I guess the only way I could solve it is if there is a way to
set global variables from within a function.

(see below)

Lee wrote:
My problem deals with working with window objects between
pages as follows: Your Subject line was poorly chosen, since it gives the
impression that you are having trouble with the Math.random()
method.

It's true, but it all revolves around the problems I have in
generating 64 unique random numbers.
My Introduction page contains a link to my Action page.
The onClick of that link creates a series of random numbers
that are appended to the end of the url of the Action page.
After initiating the link the URL of the Action page
looks like this:

http://Action.htm?61,65,24,22 etc x 16.

Now a user chooses two of those numbers, say 61 and 24,

from the Action page and they are sent to a Pop-Up page.


Is the "Pop-Up page" opening in a new window, as the name
seems to imply (we've already been fooled once)? If so,
that Window can refer back to the Action page via it's
"opener" attribute.


Yes the Pop-Up opens a new page. I am not familiar with this
attribute so I will check it out.
I don't see how it will help, but you can use variables
in the window.open() call, or you can create the URL as
a variable:

var sep="?";
var URL="Action.htm ";
for(var i=0;i<16;i++){
URL+=sep+Math.f loor(Math.rando m()*100);
sep=",";
}
var ActionPage=wind ow.open(URL,"Ac tion");

Jul 20 '05 #3
Well, the opener thing works perfectly, my life is now
100% easier.

Thank you very, very much Lee.

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2501
by: Virus | last post by:
Ok well what I am trying to do is have 1.) the background color to change randomly with 5 different colors.(change on page load) 2,) 10 different quotes randomly fadeing in and out in random spots on the webpage. with a delay timer on them, so they keep changing as the page is open. Not random each time the page is loaded. If anyone can help it would be greatly appreaciated, I have tried many of
10
2901
by: Sonoman | last post by:
Hi all: I am trying to write a simple program that simulates asking several persons their birth day and it counts how many persons are asked until two have the same birth day. The problem that I have is that the first loop I get a sequence of random numbers untuil I get a match, BUT then on the following loops I get the SAME random(?) sequence. I am using rand(). I do not want to get too fancy with the random number generator, but is there...
4
2697
by: Jack | last post by:
I have two files: sort_comparison.c++ my_sort.h sort_comparison.c++ calls this code in my_sort.h: void my_sort::fillArray(int arr,int n) { // const int random_number_range=1000000;
70
6261
by: Ben Pfaff | last post by:
One issue that comes up fairly often around here is the poor quality of the pseudo-random number generators supplied with many C implementations. As a result, we have to recommend things like using the high-order bits returned by rand() instead of the low-order bits, avoiding using rand() for anything that wants decently random numbers, not using rand() if you want more than approx. UINT_MAX total different sequences, and so on. So I...
10
5983
by: Johnny Snead | last post by:
Hey guys, Need help with this random sort algorithm private void cmdQuestion_Click(object sender, System.EventArgs e) { Random rnd = new Random(); //initialize rnd to new random object System.Random iRnd = new System.Random(); string theNum = iRnd.Next(0,8).ToString(); lblAnswer.Text = iRnd.Next(0,8).ToString();
5
3348
by: Peteroid | last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers. But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0 with resolution of a double (i.e., every possible double value in the range could come up with equal probability). I'd also like to be able to seed this generator (e.g., via the clock) so that the same sequence of random values don't come up every time. Anybody have an easy and fast...
4
10584
by: fatimahtaher | last post by:
Hi, I am supposed to create a program that generates a random number and then asks the user to guess the number (1-100). The program tells the user if he guessed too high or too low. If he guessed right, it asks the user is he/she wants to play again. If the answer is yes, it generates a random number and asks the user to guess the number again. The user can exit if he enters 0. I have created the following code so far but it does not work....
13
2809
by: Peter Oliphant | last post by:
I would like to be able to create a random number generator that produces evenly distributed random numbers up to given number. For example, I would like to pick a random number less than 100000, or between 0 and 99999 (inclusive). Further, the I want the range to be a variable. Concretely, I would like to create the following method: unsigned long Random( unsigned long num )
2
5477
by: alishaikhji | last post by:
I am working on a program which will need several different integer and float random numbers at different stages, for example: - At one point, I need a random number (float) in the range 0.1 to 10.0 - At one point, I need a random number (float) in the range 0.5 to 1.5 - At one point, I need a random number (float) in the range 0.3 to 3.0 - At one point, I need a random number (float) in the range 0.1 to 10.0 Also, I need to make it sure...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9343
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9198
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.