Jump to content

HELP! How do you display SEVERAL random different images?


Guest gribble234

Recommended Posts

Guest gribble234

Hi thereHow can I display several different images in javascript, for example 5 different images from a list that are all different from one another. e.g no two images are the same as other random ones.I'm really stuck on this and need help so anything would be much appreciated!Even if anyone knows how to write 5 different random numbers I can adapt the script to include into my images.Thanks

Link to comment
Share on other sites

<script type='text/javascript'>/*Random Independent NumbersCreated by Webworldx - w3Schools*/var highest_number = 10;var num_you_want = 5;var current_list = new Array();function draw_number(){	var selected_num = Math.ceil( Math.random() * highest_number);	for(j=0;j<current_list.length;j++){		if(selected_num == current_list[j]){			//Number already selected			return draw_number();		}	}	return selected_num;}function go_get_numbers(){	if(num_you_want > highest_number){		// You can't ask for more numbers than it's possible to get		return false;		}		for(i=0;i<num_you_want;i++){		current_list[current_list.length++] = draw_number();	}	return current_list;}var independent_numbers = go_get_numbers();alert(independent_numbers);</script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...