I'm new in Java script and I'm trying to build a slideshow for my page. Here is my html code:
<div id="sildeshow">
<img src="Imagini\CEJ2016\img3.jpg" id="imag">
<div id="stanga"><img onclick='slideSHOW(-1)' class="buton_stanga" src="Imagini\left.png"></div>
<div id="dreapta"><img onclick='slideSHOW(1)' class="buton_dreapta" src="Imagini\right.png"></div>
</div>
and my Js script:
<script type="text/javascript">
var numar_imagine=1;
var maxim=14;
function slideSHOW(x){
var imagine=document.getElementById('imag');
numar_imagine +=x;
if(numar_imagine>maxim){
numar_imagine=1;
}
if(numar_imagine<0){
numar_imagine=maxim;
}
imagine.src="Imagini\CEJ2016\img" + numar_imagine + ".jpg";
}
</script>
Now, the thing is that for some reason my img source does not change properly when I press my left/right arrows.
Trying to solve the problem I noticed that if my images are in same directory with my .html file the code works.
Any advice? Thanks.
\ is escape char. your solution is below