Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Random Pictuture Creator


graysonhobby

Recommended Posts

Posted

I want to show about 10 pictures randomly every time someone comes to my site. I found a simple JavaScript code, but the apostrophe(s) keep screwing things up. I have this on my index.php page.

 

Did I over simply this addition / JavaScript?

 

If this doesn't work, what's an alternative??

 

<script language="JavaScript"><!--

//Javascript Created by Computerhope [url="http://www.computerhope.com"]http://www.computerhope.com[/url]

//store the quotations in arrays

images = new Array(4);

images[0] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner.gif' alt='Visit Computer Hope'></a>";

images[1] = "<a href = 'http://www.computerhope.com/history/index.htm'><img src='http://www.computerhope.com/banners/banner2.gif' alt='Computer History'></a>";

images[2] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner3.gif' alt='Visit Computer Hope'></a>";

images[3] = "<a href = 'http://www.computerhope.com/newslet.htm'><img src='http://www.computerhope.com/banners/banner4.gif' alt='Computer Hope Newsletter'></a>";

index = Math.floor(Math.random() * images.length);

document.write(images[index]);

//done

// --></script><br>

Posted

You can glean how to do the same thing using PHP here:

 

Click Me

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Archived

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

×
×
  • Create New...