Skip to Content
0
Former Member
Sep 30, 2005 at 06:39 AM

Random display of images!!

171 Views

Hi

I'm following the previous post and accordingly i was able to display a image on the iView.

Now I've a list of images

say image1.jpg, image2.jpg, image3.jpg and so on..

Now i want to pick any one of them and display any one of them. how do i go about this.

Following is the code which i wrote can't find the error in it.

<script type="javascript">
var images = new Array();

images[0] = "/images/birds.jpg";
images[1] = "/images/child.jpg";
images[2] = "/images/dolphin1.jpg";
images[3] = "/images/dolphin2.jpg";
images[4] = "/images/fish.jpg";
images[5] = "/images/kayak.jpg";
images[6] = "/images/man.jpg";
images[7] = "/images/pasture1.jpg";
images[8] = "/images/pasture2.jpg";
images[9] = "/images/pasture3.jpg";
images[10] = "/images/runner.jpg";

var rannum = Math.floor(Math.random()*11)
var choice = images[rannum];

</script>

<% String image2 = componentRequest.getWebResourcePath() + "/images/insidetrack3.gif"; %>
<% String image1 = componentRequest.getWebResourcePath() + "/images/pasture1.jpg";%>

<IMG SRC="<%=image1%>" WIDTH="340" HEIGHT="238" BORDER="0" ALIGN="left">
<IMG SRC="<%=image2%>" WIDTH="360" HEIGHT="238" BORDER="0">

can anyone help me out.

Thanks in advance

Srikant