I have an array that onclick randomly generates an image.
The thing is that i want to add some text to each image that also shows when onclick.
Im not sure how to add it to my existing array.
Here is how my code looks like.
This is the code that is used on my image that the user clicks on that generates a random image
<div class="fenetre">
<a href="#" onClick="pickimg2(); return false;">
<img src="image.png" name="randimg" border=0>
</a>
</div>
Here is the array of images that randomly shows when i click the image above
<script>
var myImages1 = new Array();
myImages1.push("img1.png");
myImages1.push("img2.png");
myImages1.push("img3.png");
myImages1.push("img4.png");
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function pickimg2() {
document.randimg.src = myImages1[getRandomInt(0, myImages1.length - 1)];
}
</script>
So how can i add text to my array with each image?
Thx!
2
Answers
It is my solution: