Randomizer Code?

G

gcc

What I want to do is set up on a page a List of options and have a user be
able to select different options, click enter and have it randomize those
selected options.

For Example:

I would like to create a random Diet Chart, On it will be 20 Different
Entrees, 30 Veggies, 10 Bread Selections, 20 Desserts and 10 wine selections

The user would be able to add as many or as few of each selection they would
like and also choose a number of days for the diet. Lets say they choose 10
Entrees, 20 Veggies, 5 Breads, 10 Desserts and 5 Wine selections for a Total
of 5 Days and click enter

They would then go to a results page that would look something like:

Day 1: Random Entree, Random Veggie, Random Bread etc
Day 2: Random Entree, Random Veggie....etc
Day 3: So Forth and So on.....

Does anyone know if how this can be done?
 
C

C A Upsdell

gcc said:
What I want to do is set up on a page a List of options and have a user be
able to select different options, click enter and have it randomize those
selected options.

For Example:

I would like to create a random Diet Chart, On it will be 20 Different
Entrees, 30 Veggies, 10 Bread Selections, 20 Desserts and 10 wine selections

The user would be able to add as many or as few of each selection they would
like and also choose a number of days for the diet. Lets say they choose 10
Entrees, 20 Veggies, 5 Breads, 10 Desserts and 5 Wine selections for a Total
of 5 Days and click enter

They would then go to a results page that would look something like:

Day 1: Random Entree, Random Veggie, Random Bread etc
Day 2: Random Entree, Random Veggie....etc
Day 3: So Forth and So on.....

Does anyone know if how this can be done?

Most programming languages have functions to generate (pseudo-random)
numbers: e.g. JavaScript has Math.random() . If you have (say) 20 choices,
just generate a random number from 1-20, and use this to pick the choice.

Something that complicates this is that sometimes the same choice will be
picked several times in a row, so you may want to make your code smarter by
(say) not picking something you've picked in (say) 3 days.
 
T

Toby A Inkster

gcc said:
The user would be able to add as many or as few of each selection they would
like and also choose a number of days for the diet. Lets say they choose 10
Entrees, 20 Veggies, 5 Breads, 10 Desserts and 5 Wine selections for a Total
of 5 Days and click enter

Use a server-side script. And if the number of different meals to choose
from is large (choose your own definition of 'large'), then use a database
too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top