Random Picture Selections

D

Davet102

Running Front Page 2000 (V 4.0.2.2717)
(I know, but it works for my applications)

Here is the question:

I have several pictures that I would like to have come up one at a time
randomly on one of my sites.

They only have to come up different each time someone clicks on that certain
page. They do not have to change while that person is on that page. (If I can
have that happen too that would be fine)

So fare I am having no luck figuring out how to do this or where to go to
find out how to do this.

That is why I am here.

Help please!!

Thanks

Bob
 
T

Trevor Lawrence

Davet102 said:
Running Front Page 2000 (V 4.0.2.2717)
(I know, but it works for my applications)

Here is the question:

I have several pictures that I would like to have come up one at a time
randomly on one of my sites.

They only have to come up different each time someone clicks on that
certain
page. They do not have to change while that person is on that page. (If I
can
have that happen too that would be fine)

So fare I am having no luck figuring out how to do this or where to go to
find out how to do this.

That is why I am here.

Help please!!


Bob,
The code below selects a new image every time the page loads and when the
button is clicked. Sometimes the image does not change but that is because
the same number can be selected randomly

It would also be possible to set a rotation that changes every x seconds if
you want it

html>
<head>
<script type="text/javascript">
// Set up the image files to be used.
var theImages = new Array( // do not change this
/****************************************************
* To add more image files, continue with the *
* pattern below, adding to the array, *
* with a bracket after the last. *
****************************************************/
'images/1.jpg' ,
'images/2.jpg' ,
'images/3.jpg' ,
'images/4.jpg' )

// do not edit anything below this line
for (var preBuffer = new Array(), i = 0, p = theImages.length; i < p ; i++){
preBuffer = new Image()
preBuffer.src = theImages
}
function showImage() {
document.images['myImage'].src=
theImages[Math.round(Math.random()*(p-1))];
}
</script>
</head>
<body onload="showImage();">
<p>
<button id="button1" onclick="showImage();">
Click to change image</button>
</p>
<img id="myImage" src=" ">
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top