Witam, mam taki prosty skrypt w js, niestety nigdy sie nie bawilem w js i juz jako dla mnie to jest abstrakcja!
  1. <?php
  2. <script type='text/javascript'>
  3. var ss1;
  4. window.onload = function()
  5. {
  6. // Create slideshow object
  7. ss1 = new xSlideShow(2000, 'slideshow1', '../../images/',
  8.  ['avatar.jpg', 'cb_x.gif', 'eyeinhand_75x74.gif', 'mars.gif', 'usflag.jpg', 'veil_nebula.jpg', 'ss.jpg'],
  9.  ['../../', '../x/lib/', '../../toys', 'vtb_with_tpg.html', 'xanimation.php', 'drag4.php', 'xsplitter.html'],
  10.  ['Home', 'X Library', "Mike's Toys", 'xTabPanelGroup', 'xAnimation', 'Drag-n-Drop', 'xSplitter']);
  11.  
  12. // Initialize buttons
  13. if (ss1) {
  14. var b = document.getElementById('btnPrev');
  15. b.onclick = function() { ss1.prev(); };
  16. = document.getElementById('btnAuto');
  17. b.onclick = function() { ss1.start(); };
  18. = document.getElementById('btnNext');
  19. b.onclick = function() { ss1.next(); };
  20. }
  21. }
  22. /*
  23.   xSlideShow - A simple slideshow object.
  24.  
  25.   uInterval - The time in milliseconds for auto-slide.
  26.   sImgEleId - The IMG element in the HTML.
  27.   sImagePath - The path to be prepended to each image file name.
  28.  It must have a trailing backslash.
  29.   aFiles  - An array of image file names.
  30.   aLinks  - An optional array of URLs for when the image is clicked.
  31.   aTitles - An optional array of titles for each image.
  32.  
  33.   If provided, aLinks and aTitles must have the same length as aFiles.
  34. */
  35.  
  36. function xSlideShow(uInterval, sImgEleId, sImagePath, aFiles, aLinks, aTitles)
  37. {
  38. // Private Properties
  39.  
  40. var ths = this;
  41. var tmr = null;
  42. var idx = -1;
  43. var imgs = []; // zero-based
  44.  
  45. // Private Methods
  46.  
  47. function run()
  48. {
  49. tmr = setTimeout(run, uInterval);
  50. ths.next(true);
  51. }
  52.  
  53. function onClick()
  54. {
  55. // note: In this function, 'this' points to the IMG object
  56. var t = aTitles ? aTitles[idx] + ': ' : '';
  57. if (confirm('Do you want to visit the following page?\n' + t + aLinks[idx])) {
  58. window.location = aLinks[idx];
  59. }
  60. }
  61.  
  62. // Public Methods
  63.  
  64. this.start = function()
  65. {
  66. if (tmr == null) {
  67. run();
  68. }
  69. else {
  70. this.stop(); // implements a 'toggle'
  71. }
  72. };
  73.  
  74. this.stop = function()
  75. {
  76. if (tmr != null) {
  77. clearTimeout(tmr);
  78. tmr = null;
  79. }
  80. };
  81.  
  82. this.next = function(bRunning)
  83. {
  84. var i = document.getElementById(sImgEleId);
  85. if (i) {
  86. if (!bRunning) {
  87. // stop auto-slide unless next() is called from run()
  88. this.stop();
  89. }
  90. if (++idx >= imgs.length) {
  91. idx = 0;
  92. }
  93. i.src = imgs[idx].src;
  94. if (aTitles) {
  95. i.title = aTitles[idx];
  96. }
  97. }
  98. };
  99.  
  100. this.prev = function()
  101. {
  102. var i = document.getElementById(sImgEleId);
  103. if (i) {
  104. this.stop(); // stop auto-slide
  105. if (--idx <= 0) {
  106. idx = imgs.length - 1;
  107. }
  108. i.src = imgs[idx].src;
  109. if (aTitles) {
  110. i.title = aTitles[idx];
  111. }
  112. }
  113. };
  114.  
  115. this.onunload = function()
  116. {
  117. var i = document.getElementById(sImgEleId);
  118. if (i) {
  119. i.onclick = null;
  120. }
  121. ths = null;
  122. };
  123.  
  124. // Constructor Code
  125.  
  126. var i;
  127. = document.getElementById(sImgEleId);
  128. if (i) {
  129. if (aLinks) {
  130. i.onclick = onClick;
  131. }
  132. for (= 0; i < aFiles.length; ++i) {
  133. imgs[i] = new Image();
  134. imgs[i].src = sImagePath + aFiles[i];
  135. }
  136. this.next(true); // show first image
  137. }
  138. else return null; // error
  139. }
  140. // end xSlideShow Object Prototype
  141. </script>
  142. <div>
  143. <p>
  144. <span id='btnPrev' class='btn' title='Show Previous'>Previous</span> |
  145. <span id='btnAuto' class='btn' title='Toggle Auto-Slide'>Auto</span> |
  146. <span id='btnNext' class='btn' title='Show Next'>Next</span>
  147. </p>
  148.  
  149. <p><img id='slideshow1' src='' alt=''></p>
  150. </div>
  151. ?>



Wyswietla mi zdjecia z jakiegos katalogu. Ale chcialbym aby gdy kline np w miniaturke fotki to pokaze mi sie duze zdjecie, ale tutaj to jest niemozliwe bo nie przekazuje zmiennej id dla zdjecia. Wlasnie nie wiem w jaki sposob dorobic takowa zmienna aby gdy klikne w miniaturke 4 pokaze sie zdjecie 4 5,5. Prosze o jakas pomoc, z gory dziekuje