PDA

View Full Version : javascript - random image, link AND text



Time_Bomb
08-07-2007, 06:09 PM
i cant manage to get all 3 to go together, anyone have this script?

hguy
08-07-2007, 10:46 PM
Hi,

Try with this script




<script language="JavaScript">
<!-- Hide from old browsers

var imagenumber = 3 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
var image = images[rand1]
var Quotation=new Array()

images = new Array
images[1] = "forum.gif"
images[2] = "friend.gif"
images[3] = "fun.gif"

links = new Array
links[1] = "http://www.bluehostforums.com"
links[2] = "http://www.withfriendship.com"
links[3] = "http://www.funmin.com"


Quotation[1] = "nice";
Quotation[2] = "befriendly";
Quotation[3] = "funny";

var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();


document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')

</script>




I think you can manage to have a link using text along with random image

Moderator please delete one of my post which are same. I posted twice by mistake. Oblige me.

silentcollision
08-08-2007, 12:26 AM
Thats assuming the user has javascript turned on.

Personally I would go for a PHP/MySQL solution.

Time_Bomb
08-08-2007, 09:25 AM
hguy - thanks ill try that.

silentcollision- i dont mind going with php, if you've got a script which does the same ill give that a try aswell.

Thanks