...

View Full Version : Hopefully an easy question!



icodeinpink
09-06-2011, 03:02 AM
Hey! Sorry if this is a very remedial question, but I'm trying to make a table, of even and odd numbers organized in two columns (with as many rows as it takes to get through the sequence) and I'm having an issue with my code, obviously - haha. I'm still slightly new..

here is my code


document.write('<table>');
for (i=1; i < 50; i++) {
document.write("<tr>");
for (j = 0; j < 50; j++) {
if (j % 2==0) {
document.write('<td>' + j + '</td>');
}
else
{
document.write('<td>' + i + '</td>');
}
}
}
document.write("</tr>);
document.write("</table>");

Any help would be greatly appreciated!

Philip M
09-06-2011, 11:54 AM
Sounds like homework!


<script type = "text/javascript">
document.write('<table>');
for (j = 0; j < 50; j=j+2) {
document.write("<tr>");
document.write('<td>' + j + '</td>');
document.write('<td>' + (j+1) + '</td>');
document.write("</tr>");
}
document.write("</table>");
</script>


It is your responsibility to die() if necessary….. - PHP Manual



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum