/    Sign up×
Community /Pin to ProfileBookmark

Using Prototype’s $$() and Scriptaculous to make a slideshow.

I have making a simple slide show using Prototype and Scriptaculous. This is in my javascript file, slideshow.js:

[CODE]var slideTime = 1000;
var index = 0;
var images = $$(‘.slideshow’);
var numImages = images.length;

document.observe(‘dom:loaded’, function(){
setInterval(slide(), slideTime);
});

function slide(){
if (index == numImages – 1) {
index = 1;
images[0].appear();
images.each(function(ele){
ele.show();
});
} else images[index++].fade();
}[/CODE]

and here is my index.html file:

[code=html]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<link type=”text/css” rel=”stylesheet” media=”all” href=”main.css”>
<script src=”lib/prototype/prototype.js” type=”text/javascript”></script>
<script src=”lib/scriptaculous/scriptaculous.js” type=”text/javascript”></script>
<script src=”lib/slideshow.js”></script>

<title>New Web Project</title>
</head>
<body>
<h1>New Web Project Page</h1>
<img id=”slideshow” src=”images/gold.png” class=”slideshow” alt=””></a>
<img id=”img2″ src=”images/header-image.png” class=”slideshow” alt=””>
<p id=”output”>!!!</p>
<p id=”output2″>###</p>
</body>
</html>
[/code]

When I do this absolutely nothing happens in the browser (FireFox or IE). None of the images fade.

What am I doing wrong?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @livewire1337 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...