I have a PSP page with html embedded. I need to place another for loop so i can insert another %s next to background-color: which will instert a appropriate colour to colour in the html table.
For example i need to insert for z in colours so it can loop over the colours list and insert the correct colour. Where ever i try to insert the for loop it doesnt seem to work it most commonly colours each cell in the table 60 times then moves onto the next cell and repeats itself and crashes my web browser.
The colours are held in a table called colours.
code below:
<table>
<%
s = ''.join(aa[i] for i in table if i in aa)
for i in range(0, len(s), 60):
req.write('<tr><td><TT>%04d</td>' % (i+1));
for k in s[i:i+60]:
req.write('<TT><td><TT><font style="background-color:">%s<font></td>' % (k));
req.write('</TT></tr>')
#end
%>
</table>
-----EDITED-----
Plugged in the code provided ebo, it colours the table all one colour. The colours list contains a variety of colours e.g. colour = ['yellow', 'yellow', 'yellow', 'yellow', 'red', 'red', 'red', 'red']
<table>
<%
s = ''.join(aa[i] for i in table if i in aa)
for i in range(0, len(s), 60):
req.write('<tr><td>%04d</td>' % (i+1));
for j, k in enumerate(s[i:i+60]):
req.write('<td><font style="background-color:%s;">%s<font></td>' % (colour[j % len(colour)], k));
req.write('</tr>')
#end
%>
</table>
for kdoing? Which number is meant to be an index into the colours table? Is it justi? In that case it should becolours[i % len(colours)].s? What does it have to do withcolours? Can you be more precise about the ordering of the sequence you want to get out?