Log in

View Full Version : Random Image Load



Flock001
03-31-2010, 01:48 PM
Hi, Can you help at all please.
I am looking for a script whereby a new client testimonial will load into the page each time the page is opened.
It doesn't need to tween between other testimonials it just m=needs to load a new random message each time.

Many thanks in advance.

Nile
03-31-2010, 02:13 PM
PHP:


<?php
$message = array("Welcome to my site!", "Hello World.", "Wassup?");
echo $message[rand(0, count($message)-1)];
?>

JS:

<script type="text/javascript">
var messages = ["Welcome to my site!", "Hello World.", "Wassup?"];
alert(messages[Math.floor(Math.random()*messages.length)]);
</script>

Flock001
04-01-2010, 02:34 PM
Thanks, but not quite what I had in mind.

The random message will actually be within the website screen itslef and will be a testimonial. Probably as a image.

Nile
04-02-2010, 01:08 AM
So use the php one. Or does your server not support PHP?