Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Random image


Guest

Recommended Posts

Posted

I want to add a bit of code that when you refresh your page the image you have on the page changes, like this sit http://www.lesbian-central.co.uk/

I have tried different javascript codes and php but with no luck, they just error messages when i enter them in to the english index.php

 

i have tried this

 

<script language="JavaScript">

<!--

 

function random_imglink(){

var myimages=new Array()

//specify random images below. You can have as many as you wish

myimages[1]="http://www.henkvrieselaar.nl/flowers/bloem1.jpg"

myimages[2]="http://www.henkvrieselaar.nl/flowers/bloem2.jpg"

myimages[3]="http://www.henkvrieselaar.nl/flowers/bloem3.jpg"

myimages[4]="http://www.henkvrieselaar.nl/flowers/bloem4.jpg"

myimages[5]="http://www.henkvrieselaar.nl/flowers/bloem5.jpg"

 

 

//specify corresponding links below

var imagelinks=new Array()

imagelinks[1]="http://www.realmacsoftware.com"

imagelinks[2]="http://www.apple.com"

imagelinks[3]="http://www.yourhead.com"

imagelinks[4]="http://www.cnn.com"

imagelinks[5]="http://www.henkvrieselaar.nl"

 

var ry=Math.floor(Math.random()*myimages.length)

 

if (ry==0)

ry=1

document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')

}

 

random_imglink()

//-->

</script>

 

 

and this

 

<img src="http://path_to_images/header_<?php echo(rand(1,5)); ?>.jpg"

width="image_width" height="image_height" alt="image_alt_text" />

 

this one doesn't give an error message but it just doesn't display the image/s.

 

I can't see anything in the forums or contributions that can help.

 

any help would be cool

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...