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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:14:32+00:00 2026-06-04T16:14:32+00:00

I have this Javascript sliding image script. It works great, but I would like

  • 0

I have this Javascript sliding image script. It works great, but I would like to add text in the form of a paragraph tag to the sliding effect, one paragraph accompanying each image in the slide. How to do that?
My code:

<script language="JavaScript">
var image = new Array("images/ref1.png", "images/ref2.png", 
                "images/bb.png", "images/windows.png")
                var imgNumber=1     
                var numberOfImg = image.length                  

                function previousImage(){
                  if(imgNumber > 1){
                    imgNumber--
                    }

                  else{
                    imgNumber = numberOfImg
                    }

                  document.slideImage.src = image[imgNumber-1]                              
                  }

                function nextImage(){
                  if(imgNumber < numberOfImg){
                    imgNumber++
                    }

                  else{
                    imgNumber = 1
                    }

                  document.slideImage.src = image[imgNumber-1]  
                  }

                if(document.images){                                       
                   var image1 = new Image()                                        
                   image1.src = "images/ref1.png"
                   var image2 = new Image()
                   image2.src = "images/ref2.png"
                   var image3 = new Image()
                   image3.src = "images/bb.png"
                   var image4 = new Image()
                   image4.src = "images/windows.png"
                   }
</script>
<table>
        <tr>
          <td><img src="images/ref1.png" name="slideImage"></td>
        </tr>
        <tr>
          <td><a href="JavaScript:previousImage()">
          <img src="" border="none"/>prev</a>
          </td>
          <td><a href="JavaScript:nextImage()">
          <img src="" border="none" />next</a>  
          </td>
        </tr>
</table>

Thank You

  • 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-04T16:14:34+00:00Added an answer on June 4, 2026 at 4:14 pm

    Basically you just need to add an element to hold your text, an array that contains the text to rotate, and add a little JavaScript to make the changes.

    Here’s a jsFiddle example.

    I added a new paragraph element with the ID of ‘text’ to your HTML, and in your JavaScript I created an array to hold the text. The text gets changed just like the images do using this line: document.getElementById('text').innerHTML = text[imgNumber - 1];.

    JavaScript:

    var image = new Array("http://www.dummyimage.com/60x60/&text=1", "http://www.dummyimage.com/60x60/&text=2", "http://www.dummyimage.com/60x60/&text=3", "http://www.dummyimage.com/60x60/&text=4");
    var text = new Array('one', 'two', 'three', 'four');
    var imgNumber = 1;
    var numberOfImg = image.length;
    
    function previousImage() {
        if (imgNumber > 1) {
            imgNumber--;
        }
        else {
            imgNumber = numberOfImg;
        }
        document.slideImage.src = image[imgNumber - 1];
        document.getElementById('text').innerHTML = text[imgNumber - 1];
    }
    function nextImage() {
        if (imgNumber < numberOfImg) {
            imgNumber++;
        }
        else {
            imgNumber = 1;
        }
        document.slideImage.src = image[imgNumber - 1];
        document.getElementById('text').innerHTML = text[imgNumber - 1];
    }
    if (document.images) {
        var image1 = new Image();
        image1.src = "http://www.dummyimage.com/60x60/&text=1";
        var image2 = new Image();
        image2.src = "http://www.dummyimage.com/60x60/&text=2";
        var image3 = new Image();
        image3.src = "http://www.dummyimage.com/60x60/&text=3";
        var image4 = new Image();
        image4.src = "http://www.dummyimage.com/60x60/&text=4";
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Javascript snippet in my application to prevent clickjacking: <script language=javascript type=text/javascript>
i have this javascript function: print <<"EOT"; <script type="text/javascript"> function alertSize() { var myWidth
i have this javascript code to which i want to add the jquery fade-in
I have this javascript code <Script> function getGroupId(){ var group=document.getElementById(selectedOptions).value; var groupFirstLetter=group.substring(2); } </Script>
I have this javascript code : $(.linksColl a li).hover(function () { $(this).css({ background-image :
I have this javascript code but when i send this: asd.JPG the regex fails
I have this Javascript data: [{id:123,type:test},{id:154,type:another}] How would you transform that into something so
I have a sliding boxcaption and it works fine. But when you first view
I have got some markup that looks like this: <div class=button> <span class=image></span> <input
i have the following jquery: <script type=text/javascript src=./js/jquery-1.7.2.min.js></script> <script type=text/javascript> $(document).ready(function() { $(.indexSlideMenu1_Folder div).click(function()

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.