Well I have the img
tag and when I click on a div with id="btnsiguiente"
I change the path of img
, doing this with javascript is easy if I create an array with the routes inside but if the routes of the I have images in a database as I would?
This is my javascript code:
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<link rel="stylesheet" href="cssstack.css">
</head>
<script>
var rutas=["images/img1.jpeg","images/img2.jpeg","images/im3.jpg","images/img4.jpg"];
var img;
var x=-1;
function siguiente()
{
btnsiguiente=document.getElementById("btnsiguiente");
btnsiguiente.addEventListener("click",siguiente_img,false);
}
function siguiente_img()
{
x++;
img=document.getElementsByTagName("img");
img[0].src=rutas[x];
}
window.onload=siguiente;
</script>
<body>
<div >
<img src="" width="200px" heigth="300px" />
</div>
<div id="btnsiguiente">
</div>
</body>
</html>
How would I edit the script if the routes are pulled from the database?