Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Randomizer Code?

Reply
Thread Tools

Randomizer Code?

 
 
gcc
Guest
Posts: n/a
 
      05-25-2004
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?



 
Reply With Quote
 
 
 
 
C A Upsdell
Guest
Posts: n/a
 
      05-25-2004
"gcc" <(E-Mail Removed)> wrote in message
news:U7Ksc.487$(E-Mail Removed).. .
> 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.



 
Reply With Quote
 
 
 
 
Toby A Inkster
Guest
Posts: n/a
 
      05-25-2004
gcc wrote:

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

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image randomizer not working matt Javascript 4 01-19-2004 02:08 PM



Advertisments