Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-28-2008, 03:34 AM   PM User | #1
Bob42
Regular Coder

 
Join Date: Jul 2007
Posts: 100
Thanks: 1
Thanked 0 Times in 0 Posts
Bob42 is an unknown quantity at this point
help with some code inside a for loop

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?

Code:
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>');
}
Bob42 is offline   Reply With Quote
Old 08-28-2008, 04:52 AM   PM User | #2
Pramit
New Coder

 
Join Date: Feb 2007
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Pramit is an unknown quantity at this point
I am not sure but his might help

Code:
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 %4 == 0)
        {
                document.write('</tr>');
        }
}
Pramit is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:27 AM.


Advertisement
Log in to turn off these ads.