Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am a teacher and although I am pretty good with technology my coding knowledge is very limited. I have made an activity in google sites for my students. I am wanting to put a random image generator on the last page of my site. The theme is Christmas presents so I really just want them to click a button (preferably an image of a christmas present) and then a random Christmas gift appears ie. new nikes, an ipad, a tv, basketball, football, soccerball, movies,etc. Can you help me with this?

What I have tried:

I have googled and lots of code comes up that I can copy/edit to my images but I am not sure how to make it work in a google site.
Posted
Updated 6-Dec-17 16:33pm

Quote:
Christmas gift appears ie. new nikes, an ipad, a tv, basketball, football, soccerball, movies,etc

First you need an algorithm to implement the idea:
1. Create (photo shoot or draw them using any graphic tools) and save the gift images on the computer.
2. In the code, initialize an array that stores the file paths to those images.
3. On clicking a lucky draw button, go to 4.
4. Generate a random number in the range of the index numbers of those file paths in that array.
5. Display the image found at the file path indexed at the generated random number as the gift.
6. Go to 3.
Next, you only need to pick a programming language to write the code, Google is your best assistant.
 
Share this answer
 
v4
Quote:
How do I make a random image generator?

This is not what you want.
Quote:
a random Christmas gift appears ie. new nikes, an ipad, a tv, basketball, football, soccerball, movies,etc.

You need to build a collection of pictures.
When you want to display one of them, choose it randomly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900