Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Przycisk do galerii
darksiders94
post
Post #1





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 23.06.2014

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


Ktoś mi powie dlaczego takie coś nie działa poprawnie?
Wciskam przycisk wstecz i działa tylko pierwszy element funkcji: czyli z indeksu 1 do 0. Reszta nie działa. Rzecz jasna chodzi o przycisk do galerii


function wstecz(){
if(indeks = 1){
indeks--;
}else if(indeks = 2){
indeks--;
}else if(indeks = 0){
indeks = 2;
}
}

window.onload = function(){


var buttonik = document.getElementById("przycisk_poprzedni");
przycisk_poprzedni.onclick = function(){
wstecz();
}

}
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
darksiders94
post
Post #2





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 23.06.2014

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


HTML

<!DOCTYPE html PUBLIC>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="skrypty.js"></script>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="container">
<!-- -----------------------------SEKCJA1---------------------------------- -->
<div id="sekcja1">
<div id="panel">
<div id="panel-telefon">
<b>KONTAKT: 500 450 846</b>
</div>
<div id="panel-email">
<b>E-mail: pawellos110@gmail.com</b>
</div>
</div>
<div id="baner">
<div id="fotos">
<img src=""/>
<input type="button" id="przycisk_stop" value="" />
<input type="button" id="przycisk_poprzedni" value="<<Prev" />
</div>
</div>
</div>
<!-- -----------------------------SEKCJA2---------------------------------- -->
<div id="sekcja2">
<div class="clear"></div>
<div id="menu">
<div id="klocek1-menu">
<div id="klocek1-text">
<b>Główna</b>
</div>
</div>
<div id="klocek2-menu">
<div id="klocek2-text">
<b>Szablony Allegro</b>
</div>
</div>
<div id="klocek3-menu">
<div id="klocek3-text">
<b>Strony internetowe</b>
</div>
</div>
<div id="klocek4-menu">
<div id="klocek4-text">
<b>Cennik<b>
</div>
</div>
<div id="klocek5-menu">
<div id="klocek5-text">
<b>O nas</b>
</div>
</div>
</div>
<div class="clear"></div>
<div id="nowe-standardy-css3">
<b>Nowe standardy CSS3 na Twojej stronie</b>
</div>
<div id="css3">
</div>
<div class="clear"></div>
<div id="html5">
</div>
<div id="nowe-standardy-html5">
<b>Najnowsze rozwiązania HTML5 w zasięgu ręki</b>
</div>
<div class="clear"></div>
</div>
<!-- -----------------------------SEKCJA3---------------------------------- -->
<div id="sekcja3">
<div id="stopka-autorska">
<div id="stopka-autorska-text">
<b>Szablon stworzony przez: pawellos110@gmail.com</b>
</div>
</div>
</div>
</div>
</body>
</html>





JS



var zdjecia = new Array("obraz-slider1","obraz-slider2","obraz-slider3");

const FOTY = "zdjecia/";
const SEC = 1000;
const ZMIANA = 5*SEC;

indeks = 0;

function uaktualnij(){
var img = document.getElementsByTagName("img");
for(var i=0; i<img.length; i++){
img[i].src = FOTY + zdjecia[indeks] + ".jpg";
}

indeks++;
if(indeks==zdjecia.length)
indeks=0;

}

function wstecz(){
indeks--;
if(indeks<0)
indeks=2;
}

function startInterval(){
interval = setInterval(function(){ uaktualnij(); }, ZMIANA);
}

function stopInterval(){
clearInterval(interval);
}

window.onload = function(){
uaktualnij();
startInterval();

var but = document.getElementById("przycisk_stop");
var start = "Rozpocznij prezentację";
var stop = "Wstrzymaj prezentację";
przycisk_stop.value = stop;
przycisk_stop.onclick = function(){
if(this.value == stop){
stopInterval();
this.value = start;
}else{
startInterval();
this.value = stop;
}
}

var buttonik = document.getElementById("przycisk_poprzedni");
przycisk_poprzedni.onclick = function(){
wstecz();
}

}
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 11.10.2025 - 12:17