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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:10:34+00:00 2026-05-30T20:10:34+00:00

Im have written a small function that basically takes the currentPosition value as a

  • 0

Im have written a small function that basically takes the currentPosition value as a parameter works out if that number is equal to the overall number of slides and if it isnt adds 1 to the value, unfortunately though my incremented number never seems to move from 1. Can anyone advise me where I may be going wrong?

var currentPosition = 0;
            var slideWidth = 320;
            var numberOfSlides = sliderSlides.children.length;
            console.log('Number of slides = ', numberOfSlides);

            //Remove scrollbar in js
            sliderCtn.style.overflow = 'hidden';  

            //Set .slides width equal to total width of all slides
            sliderSlides.style.width = slideWidth * numberOfSlides + 'px';                      

            // Direction click handlers
            sliderDirNext[det.clickEvent] = function(e) {               
                next(currentPosition);
                sliderSlides.style.left = slideWidth*(-currentPosition) + 'px';         
                console.log('Slide width ', slideWidth);
                stopEvent(e);
            };

 function next(currentPosition){
                    if( currentPosition === numberOfSlides ) {
                        return false;
                    } else {
                        currentPosition += 1;
                        console.log('Next current position = ', currentPosition);
                        return true;
                    }
                } 
  • 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-30T20:10:36+00:00Added an answer on May 30, 2026 at 8:10 pm

    Solution. Though, there is most likely a better one if you provide more context:

    window.currentPosition = 0;
    
    function next(){
        if( currentPosition === numberOfSlides ) {
            return false;
        } else {
            currentPosition += 1;
            console.log('Next current position = ', currentPosition);
            return true;
        }
    } 
    

    After OP Update:

    Simply removing the next function currentPosition parameter should resolve your issue, given the rest of your logic is sound.

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

Sidebar

Related Questions

I have written a small function in Emacs that does a git stash git
I have written a small chat app that uses mysql + php to facilitate
I have written a small app that puts my bluetooth in discoverable mode for
In Ruby I have often written a number of small classes, and had a
I have written a small function, which uses ElementTree and xpath to extract the
I have the following function that is used as the glutKeyboardFunc function parameter: void
I am still new to Javascript and JQuery. I have written a small function
I have written some code in which a small part of the code takes
I have written a small jquery application that allows a person to slide a
I have written a small program which uses function pointers to do some numerical

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.