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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:49:19+00:00 2026-06-15T20:49:19+00:00

Relative JavaScript newbie here looking for some help in creating a scrollable thumbnail slider

  • 0

Relative JavaScript newbie here looking for some help in creating a scrollable thumbnail slider using JavaScript/AJAX/HTML.

By ‘scrollable thumbnail slider’ I mean a set of thumbnail images wedged between ‘left’ and ‘right’ arrow images. Clicking either arrow should alter the set of thumbnails displayed WITHOUT reloading/refreshing the rest of the page. As an example please see this page: http://www.travelzoo.com/local-deals/Boston/Entertainment/34729.

Here’s my code thus far:

<div id="thumbnails">
  <a href="#" onclick="slideLeft()"><img src="left_arrow.jpg"/></a>
  <script>
    //I only want to display 4 thumbnails at a time, but may have many more cached
    for (var i=0;i<4;i++)
    {
       // don't worry about the formula below, it simply manipulates the imgCounter var
      document.write('<a href=""><img src="sampleImage'+(((parseInt(imgCounter)+i-1)%4)+1)+'.jpg"/></a>');
    } 
  </script>
  <a href="#" onclick="slideRight()"><img src="right_arrow.jpg"/></a>
</div>

<script>
  ...

  function slideLeft() {
    //imgCounter is a passed var, updated when either arrow is clicked
    imgCounter = (parseInt(imgCounter)+3)%4;
    if (imgCounter == 0)
      imgCounter = 4;
    }
  ...
</script>

When the user clicks the left or right arrow, the variable representing the first image (imgCounter) is updated. I then want to redraw the DIV (id=”thumbnails”) with this updated variable while leaving the rest of the page AS IS.

Can this be done with pure JavaScript?
If not, can someone please provide a basic AJAX example?

If you feel that this question has already been answered (I checked) or is not adequately explained, please don’t be a jerk/troll and politely suggest what additional info I can provide.

Thanks!

  • 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-15T20:49:20+00:00Added an answer on June 15, 2026 at 8:49 pm

    Ok, so I figured this out myself. As I suspected, I was over-thinking it…

    I wrote a helper function that generates the innerHTML code for my div, as follows:

    function generateThumbHTML() {
      var html = '';
    
      for (var i=0;i<4;i++)
      {
        html += '<a href=""><img src="sampleImage';
        html += '(((parseInt(imgCounter)+i-1)%4)+1)';
        html += '.jpg"/></a>';
      }
    
      return html;
    }
    

    Then, I added a call to my slideLeft() and slideRight() functions, setting the innerHTML property of my DIV to the new HTML code:

    <script>
      ...
    
      function slideLeft() {
        //imgCounter is a passed var, updated when either arrow is clicked
        imgCounter = (parseInt(imgCounter)+3)%4;
        if (imgCounter == 0)
          imgCounter = 4;
    
        var container = document.getElementById("thumbnails");
        container.innerHTML = generateThumbHTML();
      }
      ...
    </script>
    

    The only remaining question I’m trying to answer is this…

    Why does updating the innerHTML property automatically kick in? Is there an event that takes place in the background as soon as this property is updated? And if so, how can I find out what events are being fired? I’m looking at the HTML DOM spec but am not finding the innerHTML property on any object definition.

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

Sidebar

Related Questions

Having such an html: <a class=someclass href=some/url/absolute/or/relative>Blah</a> ... along with such javascript: $(a.someclass).onclick(function() {
I have some JavaScript that is making an Ajax call to a relative url
Using Javascript how would I remove any number of ../ from a relative path?
I want to get the relative URL from an absolute URL in JavaScript using
I am trying to print a table using javascript the table html is like
Javascript newbie here, just trying to tweak this bit of code. It checks for
Relative newcomer to Javascript and looking for a way to remove the last character
I want to know if the url is relative or no using javascript. Basically
Relative JS newbie here trying to understand the difference between two ways of defining
Using javascript - we can set the element relative position such as object.style.position=absolute||fixed||relative But,on

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.