Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 4th, 2003, 11:05 PM
Registered User
Join Date: Jun 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple image cycling

I've got a problem with image animations. I made two images and wrote some JavaScript to change between the two every quarter second. Basically, the src attribute of the image is being changed. Anyway, I don't know how to modify the script for more than one! I thought if all of them had the same value for the name attribute, they'd all be changing. Nope, didn't work. What's the best way to get all of them to undergo the changing?

What do you see, Atrus?

Bow before me, for I am root.
Reply With Quote
  #2 (permalink)  
Old June 6th, 2003, 02:47 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo

here's how you can do it.

var myimages = new Array('image1.gif','image2.gif','images3.gif','ima ges4.gif');

function swapIt() {
var i = 0;
if(i!=myimages.length) {
    document.getElementById('name_of_a_picture_in_html ').src = myimages[i];
    i++; }
else return false;

setTimeout("swapIt(" + i + ")",100);


remember that you need to have teh function invoked, say after document.onLoad and also have a image named "name_of_a_picture_in_html" in the html body


<img src="image1.gif" name="name_of_a_picture_in_html">

that should do it

the genuine genius
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Image Uploading? courtney_ctisn Classic ASP Basics 0 October 12th, 2007 05:35 AM
Cycling through all text boxes sjf905 C# 2 September 21st, 2006 12:43 AM
Cycling through ImageButtons spacky001 C# 2 September 3rd, 2006 04:40 AM
SetTimeout Image Cycling in Circle sasidhar79 Javascript 7 July 3rd, 2004 12:30 AM
Cycling through each record in ASP with MS Access imercha ASP.NET 1.0 and 1.1 Basics 1 March 29th, 2004 02:51 AM

All times are GMT -4. The time now is 01:52 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.