Next and Back Button not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zaeta25
    New Member
    • Aug 2016
    • 1

    Next and Back Button not working

    I have the following code from another website, its working fine there, but when I want to use it in another place I have an error about SCRIPT5009: 'swapImage' is undefined


    Code:


    Code:
    <img width="100%" height="100%" id="mainImage" style="border: 1px solid black; border-image: none;" alt="" src="/services/PublishingImages/Slideshow/Slide1.JPG">
    
    <script type="text/javascript">
                // <![CDATA[
                var currentIndex = 1;
    
                //*********NOTE: Set this value to the number of slides you have in the presentation.
                var maxIndex = 17;
    
                function swapImage(imageIndex) {
                    if (imageIndex > maxIndex) {
                        currentIndex = maxIndex;
                        return;
                    }
    
                    if (imageIndex < 1) {
                        currentIndex = 1;
                        return;
                    }
    
                    currentIndex = imageIndex;
                    document.getElementById("mainImage").src = '/services/PublishingImages/Slideshow/Slide' + currentIndex + '.JPG';
                    return;
                }
            </script>

    Any Suggestion it will be appreciated.

    Thanks
    Last edited by Dormilich; Aug 24 '16, 07:06 AM. Reason: please use code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    what does 'in another place' mean exactly in your case? the error indicates that the method you want to call isnt found in that scope - so it would be better to see more of the code or an online testcase.

    Comment

    Working...