Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JavaScript] Slajdy
Forum PHP.pl > Forum > Po stronie przeglądarki > JavaScript
shy
Witam, mam problem z modyfikacją skryptu. Wyświetla on obrazki w kolejności losowej. Chciałbym aby wyświetlał je po kolei od pierwszego do ostatniego i tak w kółko ;-)

Bardzo proszę o pomoc

  1. <script language="javascript">
  2.  
  3. var delay=3000 // czas zmiany obrazka (w ms)
  4.  
  5. var curindex=0
  6.  
  7. var randomimages=new Array()
  8.  
  9. randomimages[0]="_img/slajdy/s01.jpg"
  10. randomimages[1]="_img/slajdy/s02.jpg"
  11. randomimages[2]="_img/slajdy/s03.jpg"
  12. randomimages[3]="_img/slajdy/s04.jpg"
  13. randomimages[4]="_img/slajdy/s05.jpg"
  14. randomimages[5]="_img/slajdy/s06.jpg"
  15. randomimages[6]="_img/slajdy/s07.jpg"
  16.  
  17.  
  18.  
  19. var preload=new Array()
  20.  
  21.  
  22.  
  23. for (n=0;n<randomimages.length;n++)
  24.  
  25. {
  26.  
  27. preload[n]=new Image()
  28.  
  29. preload[n].src=randomimages[n]
  30.  
  31. }
  32.  
  33.  
  34.  
  35. document.write('<img name="defaultimage" src="'+randomimages[Math.floor(Math.random()*(randomimages.length))]
  36. +'">')
  37.  
  38.  
  39. function rotateimage()
  40.  
  41. {
  42.  
  43. if (curindex==(tempindex=Math.floor(Math.random()*(randomimages.length))
  44. )){
  45.  
  46. curindex=curindex==0? 1 : curindex-1
  47.  
  48. }
  49.  
  50. else
  51.  
  52. curindex=tempindex
  53. document.images.defaultimage.src=randomimages[curindex]
  54.  
  55. }
  56. setInterval("rotateimage()",delay)
  57. </script>
trueblue
  1. function rotateimage(){
  2. document.images.defaultimage.src=randomimages[curindex];
  3. curindex++;
  4. curindex=curindex>=randomimages.length?0:curindex;
  5. }
shy
Dziękuję
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.