By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,641 Members | 2,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,641 IT Pros & Developers. It's quick & easy.

Next and Back Button not working

P: 1
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:


Expand|Select|Wrap|Line Numbers
  1. <img width="100%" height="100%" id="mainImage" style="border: 1px solid black; border-image: none;" alt="" src="/services/PublishingImages/Slideshow/Slide1.JPG">
  2.  
  3. <script type="text/javascript">
  4.             // <![CDATA[
  5.             var currentIndex = 1;
  6.  
  7.             //*********NOTE: Set this value to the number of slides you have in the presentation.
  8.             var maxIndex = 17;
  9.  
  10.             function swapImage(imageIndex) {
  11.                 if (imageIndex > maxIndex) {
  12.                     currentIndex = maxIndex;
  13.                     return;
  14.                 }
  15.  
  16.                 if (imageIndex < 1) {
  17.                     currentIndex = 1;
  18.                     return;
  19.                 }
  20.  
  21.                 currentIndex = imageIndex;
  22.                 document.getElementById("mainImage").src = '/services/PublishingImages/Slideshow/Slide' + currentIndex + '.JPG';
  23.                 return;
  24.             }
  25.         </script>

Any Suggestion it will be appreciated.

Thanks
Aug 23 '16 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,327
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.
Aug 26 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.