PDA

View Full Version : Random image, random text?


likegluelikecrew
10-05-2005, 05:04 PM
Ok, here's what I'm trying to do... I have a small table in my nav bar that has a graphic gif of text going across the top of it, then regular text in the middle, and a graphic gif at the bottom to form a little message box. I have about 4 or 5 different ones that I made into library items which are basically the same exact message box but with different text messages in the middle of them. Is there any way I can have a random one show up in the nav bar each time a person goes to or refreshes the page, and also have each random text message link to a different page?

Any help is greatly appreciated, thanks...

We Are 138

bkendall
10-06-2005, 02:42 PM
There is a Dreamweaver extension by kaosweaver.com (advanced random images) that does this quite well, but it is with images. I know you can do a random image with native DW behaviors as well but I like the extra controls and convenience in the extension. You would have to create the entire piece as one image.

I know this can also be accomplished via JavaScript it just depends how much time you want to put into researching and figuring it out.

davidj
10-06-2005, 03:18 PM
try this

<title>Untitled Document</title>

<script language="JavaScript" type="text/javascript">

function randimage(){
images = new Array(3);

images[0] = "<img src='banner.gif'>";
images[1] = "<img src='banner2.gif'>";
images[2] = "<img src='banner3.gif'>";

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

document.getElementById('img').innerHTML = images[index];
}
</script>


</head>

<body onload="randimage()">

<div id="img"></div>

</body>
</html>

remember to insert <div id="img"></div> where you want your images to appear

and i have written this so it fires on an onLoad event