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 8023169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:29:35+00:00 2026-06-04T22:29:35+00:00

I’m trying to make a javascript slideshow that has a forward and back button.

  • 0

I’m trying to make a javascript slideshow that has a forward and back button. All I need are 8 images that I can click a button and either go to the next picture or previous. However, my code doesn’t work and I can’t figure out why. I assume it’s a simple fix but it’s late and I fee like I’ve tried everything. When I say it doesn’t work, I’m referring to that the browser either returns an error saying “unable to parse background-image” (only occurs when I remove if/then statements and only run the else part, without else in front of course) or it simply crashes, likely due to an endless loop when I try to run it with the if/then statements. Here is a jsfiddle link: http://jsfiddle.net/AZchy/. Thanks for your help!

Here is my javascript:

var images = new Array(8);
images[0] = "url('screen1.jpg')";
images[1] = "url('screen2.jpg')";
images[2] = "url('screen3.jpg')";
images[3] = "url('screen4.jpg')";
images[4] = "url('screen5.jpg')";
images[5] = "url('screen6.jpg')";
images[6] = "url('screen7.jpg')";
images[7] = "url('screen8.jpg')";
var i = 0;

function slideShowForward(){
        if(i=7){
            i = 0;
            document.getElementById("images").style.backgroundImage = images[i];
        }
        else{
            i++;
            document.getElementById("images").style.backgroundImage = images[i];
        }
}
function slideShowBack(){
        if(i=0){
            i=7;
            document.getElementById("images").style.backgroundImage = images[i];
        }
        else{
            i--;
            document.getElementById("images").style.backgroundImage = images[i];
        }
}

Here is my HTML

<body>
<div id="container">
<div id="images">
</div>
<div id="form">
<form name="buttons" action="">
    <input type="button" name="previous" value="Previous" onclick="slideShowBack()"/>
    <input type="button" name="next" value="Next" onclick="slideShowForward()"/>
</form>
</div>
</div>
</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-06-04T22:29:38+00:00Added an answer on June 4, 2026 at 10:29 pm

    Change if (i = 0) to if (i == 0). Same for if (i = 7) should be if ( i == 7).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is

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.