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

//store the quotations in arrays

var images = [], 
index = 0;

images[0] = "<a href = ''><img src='' alt='Visit Computer Hope'></a>";

images[1] = "<a href = ''><img src='' alt='Computer History'></a>";

images[2] = "<a href = ''><img src='' alt='Visit Computer Hope'></a>";

images[3] = "<a href = ''><img src='' alt='Computer Hope Newsletter'></a>";

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




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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.