Guest gribble234 Posted September 24, 2006 Share Posted September 24, 2006 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 More sharing options...
Webworldx Posted September 24, 2006 Share Posted September 24, 2006 <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 More sharing options...
thongcater Posted September 25, 2006 Share Posted September 25, 2006 If you can't see or write this code I hope you will find some another code in example in this page ! Hope you will success Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now