English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want a random image (from the choice of many) to appear on the front page of my website. I believe using Javascript would be the best method. the picture will also be a link to another URL.
Can somoebody please give me some code I could copy and paste (and tell me where to put it i.e etc.) or even suggest a good site where i could get the code myself?

Many thanks

2006-08-14 01:34:29 · 4 answers · asked by Calum H 2 in Computers & Internet Programming & Design

I'm afraid it's a basic HTML site as I am in the process of teaching myself ASP and PHP & MySQL.

2006-08-14 01:41:28 · update #1

Thanks for looking. Each picture shall have a different link

2006-08-14 01:48:08 · update #2

This may sound daft but how does Javascript know where to search for the images? Is it standard procedure to save the html page that contains the JS code in the same folder as the images?

2006-08-14 01:50:03 · update #3

4 answers

the easiest way would be to create an array of images that matches with an array of links (if you are using different links for each image, I couldn't tell from you question). Then just get a random number that is in the array range (I forget the function call for this) and display that image/link.


2006-08-14 01:44:05 · answer #1 · answered by John J 6 · 0 0

Try this link.
You will want to add a new array to hold the details of the link url.
Then change the showImage function to write the tag around the tag.

2006-08-14 02:50:18 · answer #2 · answered by AnalProgrammer 7 · 0 0

for you to try 2 concerns. a million) If the BR is the alternative of . Then replace the BR with the known cost and notice if that works. If no longer then try... 2) the path src sources of the img tags variations from rand == 6 on. try putting the finished path (with the prefix C:Usersguerrald) and notice if that corrects the catch 22 situation. wish this helps, -John

2016-09-29 06:13:17 · answer #3 · answered by wheelwright 4 · 0 0

I would suggest you to do the random logic at the server end asp/php etc. can you tell me what is your server language?

2006-08-14 01:39:32 · answer #4 · answered by gansatanswers 3 · 0 0

its actually a lot easier with PHP

2006-08-14 01:49:34 · answer #5 · answered by Anonymous · 0 0

fedest.com, questions and answers