reset password
Author Message
smahbub2
Posts: 12
Posted 22:02 May 14, 2015 |

HI. For the lab, I figured out how to have a variable row number and column number, but I don't know what to do afterwards. I know we have to make the table, but how do you do so with the variable? Is there some element like rownum="x" or something where the rows will be created for you accordingly? If anyone has some advice, a website, or some video anyone could pass along to help me I'd be grateful.

Also, does anyone know if there's a tutoring place to go on Fridays, whether at school or online? I went today but they don't offer tutoring on Fridays.

 

Last edited by smahbub2 at 22:55 May 14, 2015.
chondee
Posts: 9
Posted 22:21 May 14, 2015 |

I had office hours today if you needed help.

With document.write you can create html content, that's how you create a table.
Here's an example you can start out from:

        var colNum     = 6;
        var currCol    = 0;
        document.write("<table border ='1'>");
        document.write("<tr>");
        while(currCol < colNum){
            document.write("<td>"+currCol+"</td>");
            currCol++;
        }
        document.write("</tr>");
        document.write("</table>");

This would give you a table with 1 row and as many colums as colNum is.

Also, if you write down my name, could you please spell it correctly?

smahbub2
Posts: 12
Posted 22:59 May 14, 2015 |

Thank you for helping me. And that was my bad, I fixed the spelling of the name. Thank you again :)

smahbub2
Posts: 12
Posted 20:45 May 16, 2015 |

Hey everyone, I hate to be asking help for the third time on the same lab, but I'm seriously clueless here. The goal is to make a table with varying x and y rows/collumns for a table. And the column numbers show up fine, but only on one row, not the varying rows. It's probably a simple solution that I'm just completely oblivious to, but can anyone point out whats wrong and give me advice regarding my code. It would be a lifesaver, scratch that, a grade-saver which is much more important. Any help is appreciated. The x and y variable are given, I just didn't want to make this post longer than it' should. Here's the code:

        var colNum     = y;
        var currCol    = 1;
        var rowNum     = x;
        var currROW    = 1;
        document.write("<table border ='1'>");
        document.write("<tr>");
        while(currCol < colNum){
            document.write("<td>"+currCol+"</td>");
            currCol++;
        }
         while(currCol < rowNum){
         document.write("<td>"+currROW+"</td>");
            currROW++;
        }
        document.write("</tr>", "</td>");
        document.write("</table>");