Click here to Skip to main content
15,882,152 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to create a grid of images(3X3) using javascript. Multiple Images should reside inside each thumbnail and the images should slide continuously.

My code is as below:
<html> <head> </head> <body>
<img height="200" name="slide" width="200" /> <img height="200" name="slide1" width="200" />
<img height="200" name="slide2" width="200" /> <img height="200" name="slide3" width="200" />
<script language="JavaScript"> var i = 0; var path = new Array(); // LIST OF IMAGES path[0] = "http://www.electricprism.com/aeron/slideshow/examples/1.jpg"; path[1] = "http://www.phpf1.com/images/maxSlideShow/slideshow.jpg"; path[2] = "http://www.welie.com/patterns/images/slideshow-pro.png"; var j=0; var image= new Array(); image[0] = "http://www.electricprism.com/aeron/slideshow/examples/1.jpg"; image[1] = "http://www.phpf1.com/images/maxSlideShow/slideshow.jpg"; image[2] = "http://www.welie.com/patterns/images/slideshow-pro.png"; function swapImage() { document.slide.src = path[i]; if(i < path.length - 1) i++; else i = 0; setTimeout("swapImage()",3000); document.slide1.src = path[i]; if(i < path.length - 1) i++; else i = 0; setTimeout("swapImage()",3000); document.slide2.src = image[j]; if(j < path.length - 1) j++; else j = 0; setTimeout("swapImage()",3000); document.slide3.src = image[j]; if(j < path.length - 1) j++; else j = 0; setTimeout("swapImage()",3000); } window.> </body> </html>
But,I want my code to be more dynamic. What would be the best way to create this kind of a grid? If so, a link to a tutorial would be helpful! Thanks in advance
Posted

1 solution

I think you need this - ASP.NET Repeater with jQuery Slider[^].
 
Share this answer
 
Comments
Member 11426428 4-Feb-15 9:17am    
No. This doesn't solve my problem :(
What exactly you need then and where are you stuck?
Member 11426428 4-Feb-15 9:24am    
See my above code. In that i am able to create moving images in the grid form. But the code is not dynamic. I am repeating the same lines of code to achieve the same. How can i avoid this?
Yeah... You have to repeat. That's why I said to use Repeater. That's it. Simple to use.
Member 11426428 4-Feb-15 9:32am    
<html>
<head>
</head>
<body>
<table>
<tr>
<td>
<img height="200" name="slide" width="200" />
</td>
<td>
<img height="200" name="slide1" width="200" />
</td>
</tr>

<tr>
<td>
<img height="200" name="slide2" width="200" />
</td>
<td>
<img height="200" name="slide3" width="200" />
</td>
</tr>


</table>
<script language="JavaScript">
var i = 0;
var path = new Array();
// LIST OF IMAGES
path[0] = "http://www.electricprism.com/aeron/slideshow/examples/1.jpg"; path[1] = "http://www.phpf1.com/images/maxSlideShow/slideshow.jpg";
path[2] = "http://www.welie.com/patterns/images/slideshow-pro.png";

function swapImage() {
document.slide.src = path[i];
if(i < path.length - 1) i++; else i = 0;
setTimeout("swapImage()",3000);

document.slide1.src = path[i];
if(i < path.length - 1) i++; else i = 0;
setTimeout("swapImage()",3000);

document.slide2.src = path[i];
if(i < path.length - 1) i++; else i = 0;
setTimeout("swapImage()",3000);

document.slide3.src = path[i];
if(i < path.length - 1) i++; else i = 0;
setTimeout("swapImage()",3000);
}
window.>
</body>
</html>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900