Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old April 15th, 2004, 09:57 AM
poodle poodle is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 7 poodle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Image changes with multiple arrays (javascript)

Hiya

what I'm trying to do is as follows:

click one of 4 links, each link corresponds to an array with image name in. This should then start a slideshow type thing until another link is clicked which then reverts to the corresponding array and so on...

I've got it so it semi works, but the javascript timeout thingy isn't working very well.

Basically, if you click on the next link it waits until it gets to the end of the loop before it swaps. I need it to change straight away, I've tried using clearTimeout but it didn't work.

//JAVASCRIPT CODE
<script language="javascript">
<!--//
var imggap = 2000; //number of seconds * 1000

var list0 = new Array(new Array('a1img1','img1.gif'),new Array('a1img2','img2.gif'),new Array('a1img3','img3.gif'),new Array('a1img4','img4.gif'),new Array('a1img5','img5.gif'),new Array('a1img6','img6.gif'));
var list1 = new Array(new Array('a2img1','img1.gif'),new Array('a2img2','img2.gif'),new Array('a2img3','img3.gif'),new Array('a2img4','img4.gif'),new Array('a2img5','img5.gif'),new Array('a2img6','img6.gif'));
var list2 = new Array(new Array('a3img1','img1.gif'),new Array('a3img2','img2.gif'),new Array('a3img3','img3.gif'),new Array('a3img4','img4.gif'),new Array('a3img5','img5.gif'),new Array('a3img6','img6.gif'));
var list3 = new Array(new Array('a4img1','img1.gif'),new Array('a4img2','img2.gif'),new Array('a4img3','img3.gif'),new Array('a4img4','img4.gif'),new Array('a4img5','img5.gif'),new Array('a4img6','img6.gif'));
var list4 = new Array(new Array('a5img1','img1.gif'),new Array('a5img2','img2.gif'),new Array('a5img3','img3.gif'));


function chgcard(listname)
{
//document.arrays.arrayname.value = listname;
var usearray;
var i=0;

if(listname == "list0")
{
usearray = list0;
}
else if(listname == "list1")
{
usearray = list1;
}
else if(listname == "list2")
{
usearray = list2;
}
else if(listname == "list3")
{
usearray = list3;
}
else if(listname == "list4")
{
usearray = list4;
}

var chklength = (usearray.length-1);
for (i=0;i<usearray.length;i++)
{
var thistimeout = setTimeout("chgpic('"+usearray[i][1]+"','"+usearray[i][0]+"','"+i+"','"+listname+"')",imggap);
imggap = imggap+2000;
}
}

function chgpic(imgname,imgalt,imgnum,listname)
{
document.chgimg.src = imgname;
document.chgimg.alt = imgalt;

document.arrays.counter.value = imgnum;
if(imgnum == listname.length)
{
chgcard(listname);
}
}

//-->
</script>
//END JAVASCRIPT CODE

//HTML
<form name="arrays">
<input type="text" name="arrayname" value="list0">
<input type="text" name="counter" value="0">
<input type="text" name="test" value="">
</form>
LINKS:
<br><a href="javascript:chgcard('list1');">Use Array 1</a>
<br><a href="javascript:chgcard('list2');">Use Array 2</a>
<br><a href="javascript:chgcard('list3');">Use Array 3</a>
<br><a href="javascript:chgcard('list4');">Use Array 4</a>
//END HTML

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Image changes with multiple arrays (javascript)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT