Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6131667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:00:17+00:00 2026-05-23T17:00:17+00:00

I am trying to make a slideshow and I have just started playing with

  • 0

I am trying to make a slideshow and I have just started playing with making websites and the slideshow is not working and I am not sure why. I have fixed all the errors I could so now I need some help with this…

<head>
<title>Alanna's JavaScript slide show</title>
<script language="JavaScript">

var interval = 1500;
var random_display = 0;
var imageDir = "";
var imageNum = 0;
imageArray = new Array();
imageArray[imageNum++] = new imageItem(imageDir + "01.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "02.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "03.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "04.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "05.jpg");
var totalImages = imageArray.length;
function imageItem(image_location) {
    this.image_item = new Image();
    this.image_item.src = image_location;
    function get_ImageItemLocation(imageObj) {
        return (imageObj.image_item.src)
    }
    function randNum(x, y) {
        var range = y - x + 1;
        return Math.floor(Math.random() * range) + x;
    }
    function getNextImage() {
        if (random_display) {
            imageNum = randNum(0, totalImages - 1);
        }
        else {
            imageNum = (imageNum + 1) % totalImages;
        }
        var new_image = get_ImageItemLocation(imageArray[imageNum]);
        return (new_image);
    }
    function getPrevImage() {
        imageNum = (imageNum - 1) % totalImages;
        var new_image = get_ImageItemLocation(imageArray[imageNum]);
        return (new_image);
    }
    function prevImage(place) {
        var new_image = getPrevImage();
        document[place].src = new_image;
    }
    function switchImage(place) {
        var new_image = getNextImage();
        document[place].src = new_image;
        var recur_call = "switchImage('" + place + "')";
        timerID = setTimeout(recur_call, interval);
    }
<!--
// -->
</script>
</head>

<body onLoad="switchImage('slideImg1')">

<img name="slideImg1" src="01.jpg" width=500 height=375 border=0>
<img name="slideImg2" src="02.jpg" width=500 height=375 border=0>
<img name="slideImg3" src="03.jpg" width=500 height=375 border=0>
<img name="slideImg4" src="04.jpg" width=500 height=375 border=0>
<img name="slideImg5" src="05.jpg" width=500 height=375 border=0>


<a href="#" onClick="switchImage('slideImg1')">play slide show</a>

<a href="#" onClick="clearTimeout(timerID)"> pause</a>

<a href="#" onClick="prevImage('slideImg'); clearTimeout(timerID)"> previous</a>

<a href="#" onClick="switchImage('slideImg2'); clearTimeout(timerID)">next </a>

</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:00:17+00:00Added an answer on May 23, 2026 at 5:00 pm

    Missing }

        this.image_item.src = image_location;
    }    <<<<
    

    Have a go at this which is me guessing what you want

    <head>
    <title>Alanna's JavaScript slide show</title>
    <script language="JavaScript">
    var interval = 1500;
    var random_display = 0;
    var imageDir = "";
    var imageNum = 0;
    var imageArray = [];
    var place = "slideImg1";
    for (var i=0;i<5;i++) {
      imageArray[i] = new imageItem(imageDir + "0"+i+".jpg")
    }
    var totalImages = imageArray.length;
    function imageItem(image_location) { // preloads
        this.image_item = new Image();
        this.image_item.src = image_location;
    }    
    function get_ImageItemLocation(imageObj) {
        return imageObj.image_item.src;
    }
    function randNum(x, y) {
        var range = y - x + 1;
        return Math.floor(Math.random() * range) + x;
    }
    function getNextImage() {
      var imageNum = (random_display)?randNum(0, totalImages-1):(imageNum+1) % totalImages;
      return get_ImageItemLocation(imageArray[imageNum]);
    }
    function getPrevImage() {
        imageNum = (imageNum-1) % totalImages;
        return get_ImageItemLocation(imageArray[imageNum]);
    }
    function prevImage() {
        var new_image = getPrevImage();
        document[place].src = new_image;
    }
    function nextImage() {
        var new_image = getNextImage();
        document[place].src = new_image;
    }
    window.onload=function() {
      init();
    }
    function init() {
        nextImage()
        timerID = setInterval(nextImage, interval);
    }
    </script>
    </head>
    <body>
    <img name="slideImg1" src="01.jpg" width=500 height=375 border=0>
    <a href="#" onClick="init()">play slide show</a>
    <a href="#" onClick="clearTimeout(timerID)"> pause</a>
    <a href="#" onClick="prevImage(); clearTimeout(timerID)">previous</a>
    <a href="#" onClick="nextImage(); clearTimeout(timerID)">next </a>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a slideshow-like application in Java using NetBeans. I have
I am trying to make the most simple jQuery slideshow possible. I made the
Hey all, my first post :D Problem: I'm trying to make a template gallery,
I have just started looking at javascript so hopefully this will be something simple.
I'm trying to make a slideshow viewer for a number of books with chapters
I'm trying to make a full screen slideshow kind of effect jsFiddle code here
I'm trying to make a fairly simple image slideshow to replace a flash based
I am new to CSS3 transitions. I am trying to make a image slideshow
Right now I'm trying make some browser based game. But I have little questions.
Trying to make a multilingual installer - the process is working in general, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.