Simple question, I'll take NO for an answer if it's not possible.

With a random array, can I display the results multiple time on the same page. I know I can't use css, and I would rather not use php... but is there a way for me to list the script below, then just punch in a div class at several points throughout my site?

I'm using this for advertising, and I'd like to be able to display the random image and link at 10 different points on the same page. Then to edit, I'd only want to edit the one single source. I guess it would kinda be like a slot machine, and I wouldn't mind a situation where they'd all end up as the same image :-)

Any help would be great. Thanks.

<script type="text/javascript">

//Javascript Created by Computerhope http://www.computerhope.com

//store the quotations in arrays

var images = [], 
index = 0;

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);



6 Years
Discussion Span
Last Post by jonsan32

I believe a better way to state this question is: "Can I echo an array without the use of php?"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.