...

View Full Version : help with some code inside a for loop



Bob42
08-28-2008, 04:34 AM
My JavaScript code goes through a for loop and outputs pictures in a table. The problem is that if there are 36 or so pictures, the table stretches the page. After about every 4 pics, I want a </tr><tr> placed into the code. Is it possible to do that?



for (var i = 0; i < photos.length; i++)
{
document.write('<td><a href="images/' + photos[i] + '.jpg" title="Click to enlarge" rel="lytebox">');
document.write('<img src="images/' + photos[i] + '.jpg" alt="" class="small" /></a><br />');
document.write('Photo ' + (i + 1) + '</td>');
}

Pramit
08-28-2008, 05:52 AM
I am not sure but his might help



document.write('<tr>');
for (var i = 0; i < photos.length; i++)
{
document.write('<td><a href="images/' + photos[i] + '.jpg" title="Click to enlarge" rel="lytebox">');
document.write('<img src="images/' + photos[i] + '.jpg" alt="" class="small" /></a><br />');
document.write('Photo ' + (i + 1) + '</td>');
if(i &#37;4 == 0)
{
document.write('</tr>');
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum