Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


 
 
LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 08-04-2009, 03:54 AM   #1 (permalink)
Junior Member
 
Join Date: 06-29-09
Posts: 19
iTrader: 0 / 0%
Latest Blog:
None

gilbertsavier in the red
Random pictures in each table data cell

Hello, I am new to these forums, and I greet you all

Here is the problem I am having. I have a 3x3 table, and I want to use the 6 bottom cells to display linkable pictures of merchandise. I want the cells to display a different picture each time the customer visits the website. I found a javascript for diaplying a random, linkable, picture each time someone visits, but the problem is you can't put the script in each cell. It conflicts with itself somehow. The pictures rotate, but the links only go to the last set of links in the last cell.

What is the best method I can use to accomplish my goal? Or can the script below be edited in such a way as to be useable in each cell? Thanks!

<script language="javascript">

/*
Random image slideshow- By Tyler Clarke (EMAIL REMOVED - Send PM to This User Instead)
For this script and more, visit http://www.javascriptkit.com
*/

var delay=0 //set delay in miliseconds
var curindex=0

var randomimages=new Array()

randomimages[0]=["picturehere.jpg","linkhere"];
randomimages[1]=["picturehere.jpg","linkhere"];
randomimages[2]=["picturehere.jpg","linkhere"];
randomimages[3]=["picturehere.jpg","linkhere"];

var preload=new Array()

for (n=0;n<randomimages.length;n++)
{
preload[n]=new Image()
preload[n].src=randomimages[n]
}

var First=Math.floor(Math.random()*(randomimages.lengt h));
var LnkURL=randomimages[First][1];

document.write('<img onclick="Link();" name="defaultimage" src="'+randomimages[First][0]+'">')

function Link(){
if (LnkURL){
window.location=LnkURL;
}

}
function rotateimage()
{

if (curindex==(tempindex=Math.floor(Math.random()*(ra ndomimages.length)))){
curindex=curindex==0? 1 : curindex-1
}
else
curindex=tempindex
LnkURL=randomimages[curindex][1];
document.images.defaultimage.src=randomimages[curindex][0];
}

setInterval("rotateimage()",delay)

</script>
__________________
Thanks & regards,
Lokananth
<a href="http://www.mioot.com">Live Chat Software</a> By miOOt
gilbertsavier is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using php,how to grab data from a sql data table thats already stored in $data_table? 2939195631902 Web Design Lobby 0 02-06-2009 08:17 PM
Loading data form table to table? rob7676 Coding Forum 1 11-04-2008 12:37 PM
table cell and hover quartzy Coding Forum 4 02-21-2008 01:08 AM
Showing data from a table based on infos from another table! anarchoi Coding Forum 0 06-16-2007 05:58 PM
How to add link within the cell in a table minbak Coding Forum 2 03-19-2006 10:22 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 08:31 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.