I have a array that stores path to images in javascript
var imagearray=[path1,path2,path3];
Now when I use html canvas to print all the images using for loop, it shows only one image.
Here is the code for the same:
function drawImages(src, x1, y1, width, height){
var imageObj = new Image();
imageObj.onload=function(){
downloadcontext1.drawImage(imageObj, x1, y1, width, height);
}
imageObj.src = src;
}
for(index in imagearray){
drawImages(imagearray[index],x,0,100,100);
x=x+120;
}
Can you please help me out if I am making any mistake in the above code.