Randomizer Code?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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?

Re: Randomizer Code?

Quoted text here. Click to load it

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.

Re: Randomizer Code?

gcc wrote:

Quoted text here. Click to load it

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

Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

Site Timeline