Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] Slajdy, Proszę o pomoc
shy
post 6.07.2016, 09:29:46
Post #1





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 21.03.2014

Ostrzeżenie: (0%)
-----


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>
Go to the top of the page
+Quote Post

Posty w temacie
- shy   [JavaScript] Slajdy   6.07.2016, 09:29:46
- - trueblue   [HTML] pobierz, plaintext function rotateimage...   6.07.2016, 09:41:12
- - shy   Dziękuję   6.07.2016, 14:40:24


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 25.07.2025 - 10:00